External jar files

14 views
Skip to first unread message

Yunior Betancourt

unread,
Jul 5, 2018, 2:07:55 PM7/5/18
to FastClasspathScanner-Users
Hi,

I am trying to use FastClassPathScanner to search for classes on external JARs. I am not sure if this is not supported, but I assumed it was and tried the following without success:

public static void main(String[] args) throws MalformedURLException {
 
final String externalJar = "/target/externalApp.jar";
 
String jar = "file://" + externalJar;
 
ClassLoader loader = new URLClassLoader(new URL[]{new URL(jar)});

 
FastClasspathScanner scanner = new FastClasspathScanner("com.externalApp");
 scanner
.addClassLoader(loader);

 
ClassMatcher matcher = new ClassMatcher();
 scanner
.matchAllClasses(matcher);

 scanner
.scan();
}

public class ClassMatcher implements ClassMatchProcessor {
 
@Override
 
public void processMatch(Class<?> aClass) {
 
System.out.println("c: " + aClass.getName());
 
}
}

There are a couple of classes in the externalApp jar that should be found, but nothing comes up. Only classesfor the current running application and its dependencies are found (if the package filter is removed). If I print out the unique class path elements the externalApp jar is listed as one of them. I have also tried several other approachessuch as overriding the classloaders, and the classpath without success. Any ideas?

Luke Hutchison

unread,
Jul 5, 2018, 2:12:44 PM7/5/18
to Yunior Betancourt, FastClasspathScanner-Users
Hi Yunior, can you please generate verbose logs (call .verbose() before .scan()), and attach them?

--
You received this message because you are subscribed to the Google Groups "FastClasspathScanner-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fastclasspathscanne...@googlegroups.com.
To post to this group, send email to fastclasspath...@googlegroups.com.
Visit this group at https://groups.google.com/group/fastclasspathscanner-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/fastclasspathscanner-users/c64e6bc1-9893-46e9-a0e1-7999426b2398%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Yunior Betancourt

unread,
Jul 5, 2018, 2:26:04 PM7/5/18
to FastClasspathScanner-Users
2018-07-05T14:18:11.300-0400    FastClasspathScanner    FastClasspathScanner version 3.1.6
2018-07-05T14:18:11.300-0400    FastClasspathScanner    Operating system: Mac OS X 10.12.6 x86_64
2018-07-05T14:18:11.300-0400    FastClasspathScanner    Java version: 1.8.0_51 / 1.8.0_51-b16 (Oracle Corporation)
2018-07-05T14:18:11.300-0400    FastClasspathScanner    JRE jars:
2018-07-05T14:18:11.300-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/rt.jar
2018-07-05T14:18:11.300-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/charsets.jar
2018-07-05T14:18:11.300-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/deploy.jar
2018-07-05T14:18:11.300-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/nashorn.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/javaws.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/jce.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/jfr.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/jfxswt.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/jsse.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/management-agent.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/plugin.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/resources.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/ant-javafx.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/dt.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/javafx-mx.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/jconsole.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/packager.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/sa-jdi.jar
2018-07-05T14:18:11.301-0400    FastClasspathScanner    -- /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/tools.jar
2018-07-05T14:18:11.302-0400    FastClasspathScanner    -- /System/Library/Java/Extensions/MRJToolkit.jar
2018-07-05T14:18:11.308-0400    FastClasspathScanner    Finding classpath entries
2018-07-05T14:18:11.313-0400    FastClasspathScanner    -- Getting raw classpath elements
2018-07-05T14:18:11.314-0400    FastClasspathScanner    ---- Finding ClassLoaders
2018-07-05T14:18:11.318-0400    FastClasspathScanner    ------ Found ClassLoaders:
2018-07-05T14:18:11.318-0400    FastClasspathScanner    -------- java.net.URLClassLoader@78b464a7
2018-07-05T14:18:11.318-0400    FastClasspathScanner    ------ Found system modules:
2018-07-05T14:18:11.318-0400    FastClasspathScanner    -------- [None]
2018-07-05T14:18:11.318-0400    FastClasspathScanner    ------ Found non-system modules:
2018-07-05T14:18:11.318-0400    FastClasspathScanner    -------- [None]
2018-07-05T14:18:11.325-0400    FastClasspathScanner    ------ ClassLoaderHandlers:
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.AntClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.EquinoxClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.EquinoxContextFinderClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.FelixClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.JBossClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.WeblogicClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.WebsphereLibertyClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.WebsphereTraditionalClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.OSGiDefaultClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.Java9ClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    -------- io.github.lukehutch.fastclasspathscanner.classloaderhandler.URLClassLoaderHandler
2018-07-05T14:18:11.325-0400    FastClasspathScanner    ------ ClassLoader java.net.URLClassLoader@78b464a7 will be handled by io.github.lukehutch.fastclasspathscanner.classloaderhandler.URLClassLoaderHandler@420908f8
2018-07-05T14:18:11.326-0400    FastClasspathScanner    ------ java.net.URLClassLoader@78b464a7 delegates to parent sun.misc.Launcher$AppClassLoader@55f96302 with order PARENT_FIRST
2018-07-05T14:18:11.326-0400    FastClasspathScanner    ------ ClassLoader sun.misc.Launcher$AppClassLoader@55f96302 will be handled by io.github.lukehutch.fastclasspathscanner.classloaderhandler.URLClassLoaderHandler@4146cf9
2018-07-05T14:18:11.326-0400    FastClasspathScanner    ------ sun.misc.Launcher$AppClassLoader@55f96302 delegates to parent sun.misc.Launcher$ExtClassLoader@7a81197d with order PARENT_FIRST
2018-07-05T14:18:11.326-0400    FastClasspathScanner    ------ ClassLoader sun.misc.Launcher$ExtClassLoader@7a81197d will be handled by io.github.lukehutch.fastclasspathscanner.classloaderhandler.URLClassLoaderHandler@365c0cd4
2018-07-05T14:18:11.327-0400    FastClasspathScanner    ------ Finding classpath elements in ClassLoader java.net.URLClassLoader@78b464a7
2018-07-05T14:18:11.327-0400    FastClasspathScanner    -------- Found classpath element: file:/Users/fooUser/projects/cache/externalApp.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    ---------- Normalized path: /Users/fooUser/projects/cache/externalApp.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Normalizing path to: file:/Users/fooUser/projects/cache/externalApp.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    ------ Will not scan the following classpath elements from ignored ClassLoader sun.misc.Launcher$ExtClassLoader@7a81197d
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/cldrdata.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/nashorn.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/nashorn.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/nashorn.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar
2018-07-05T14:18:11.328-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Found classpath element: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ---------- Normalized path: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Normalizing path to: file:/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Found classpath element: file:/System/Library/Java/Extensions/MRJToolkit.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ---------- Normalized path: /System/Library/Java/Extensions/MRJToolkit.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Normalizing path to: file:/System/Library/Java/Extensions/MRJToolkit.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ------ Will not scan the following classpath elements from ignored ClassLoader sun.misc.Launcher$AppClassLoader@55f96302
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Found classpath element: file:/Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ---------- Normalized path: /Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Normalizing path to: file:/Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ------ Getting classpath entries from java.class.path
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Found classpath element: target/scanner-1.0-SNAPSHOT.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    ---------- Normalized path: /Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -------- Normalizing path to: target/scanner-1.0-SNAPSHOT.jar
2018-07-05T14:18:11.329-0400    FastClasspathScanner    -- Searching for "Class-Path:" entries within manifest files
2018-07-05T14:18:11.335-0400    FastClasspathScanner    ---- Scanning jarfile classpath entry /Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar (took 0.003188 sec)
2018-07-05T14:18:11.338-0400    FastClasspathScanner    ------ Manifest file META-INF/MANIFEST.MF has Class-Path entries
2018-07-05T14:18:11.338-0400    FastClasspathScanner    -------- Found Class-Path entry in manifest: dependency-jars/fast-classpath-scanner-3.1.6.jar -> /Users/fooUser/projects/scanner/target/dependency-jars/fast-classpath-scanner-3.1.6.jar
2018-07-05T14:18:11.335-0400    FastClasspathScanner    ---- Scanning jarfile classpath entry /Users/fooUser/projects/cache/externalApp.jar (took 0.003187 sec)
2018-07-05T14:18:11.339-0400    FastClasspathScanner    ---- Scanning jarfile classpath entry /Users/fooUser/projects/scanner/target/dependency-jars/fast-classpath-scanner-3.1.6.jar (took 0.000265 sec)
2018-07-05T14:18:11.344-0400    FastClasspathScanner    -- Final classpath element order:
2018-07-05T14:18:11.345-0400    FastClasspathScanner    ---- 0: /Users/fooUser/projects/cache/externalApp.jar
2018-07-05T14:18:11.345-0400    FastClasspathScanner    ---- 1: /Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar
2018-07-05T14:18:11.345-0400    FastClasspathScanner    ---- 2: /Users/fooUser/projects/scanner/target/dependency-jars/fast-classpath-scanner-3.1.6.jar
2018-07-05T14:18:11.345-0400    FastClasspathScanner    -- Scanning filenames within classpath elements
2018-07-05T14:18:11.346-0400    FastClasspathScanner    ---- Scanning jarfile classpath entry /Users/fooUser/projects/cache/externalApp.jar (took 0.014880 sec)
2018-07-05T14:18:11.346-0400    FastClasspathScanner    ---- Scanning jarfile classpath entry /Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar (took 0.002905 sec)
2018-07-05T14:18:11.347-0400    FastClasspathScanner    ------ Found whitelisted file: com/testScanner/ClassMatcher.class
2018-07-05T14:18:11.348-0400    FastClasspathScanner    ------ Found whitelisted file: com/testScanner/Scanner.class
2018-07-05T14:18:11.346-0400    FastClasspathScanner    ---- Scanning jarfile classpath entry /Users/fooUser/projects/scanner/target/dependency-jars/fast-classpath-scanner-3.1.6.jar (took 0.006231 sec)
2018-07-05T14:18:11.366-0400    FastClasspathScanner    Masking classpath files
2018-07-05T14:18:11.367-0400    FastClasspathScanner    Scanning classfile binary headers (took 0.007692 sec)
2018-07-05T14:18:11.372-0400    FastClasspathScanner    -- Parsing classfile jar:file:/Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar!/com/testScanner/ClassMatcher.class (took 0.001302 sec)
2018-07-05T14:18:11.373-0400    FastClasspathScanner    ---- Found class com.testScanner.ClassMatcher
2018-07-05T14:18:11.373-0400    FastClasspathScanner    ------ Superclass: java.lang.Object
2018-07-05T14:18:11.374-0400    FastClasspathScanner    ------ Interfaces: io.github.lukehutch.fastclasspathscanner.matchprocessor.ClassMatchProcessor
2018-07-05T14:18:11.374-0400    FastClasspathScanner    -- Parsing classfile jar:file:/Users/fooUser/projects/scanner/target/scanner-1.0-SNAPSHOT.jar!/com/testScanner/Scanner.class (took 0.000205 sec)
2018-07-05T14:18:11.374-0400    FastClasspathScanner    ---- Found class com.testScanner.Scanner
2018-07-05T14:18:11.374-0400    FastClasspathScanner    ------ Superclass: java.lang.Object
2018-07-05T14:18:11.374-0400    FastClasspathScanner    Building class graph (took 0.003899 sec)
2018-07-05T14:18:11.379-0400    FastClasspathScanner    Completed scan (took 0.066804 sec)
c
: com.testScanner.ClassMatcher
c
: com.testScanner.Scanner
2018-07-05T14:18:11.407-0400    FastClasspathScanner    Calling ClassMatchProcessors
2018-07-05T14:18:11.409-0400    FastClasspathScanner    -- Matched class: com.testScanner.ClassMatcher
2018-07-05T14:18:11.409-0400    FastClasspathScanner    -- Matched class: com.testScanner.Scanner

Luke Hutchison

unread,
Jul 5, 2018, 5:13:39 PM7/5/18
to Yunior Betancourt, FastClasspathScanner-Users
Hi Yunior, that is indeed pretty weird. Did you edit the logs at all? At the top of the log, it should have said what your whitelist and blacklist criteria were, if any. The fact that none is listed indicates that you called the constructor without any parameters: new FastClasspathScanner(). If you did, then not only should this scan have found classes in your externalApp.jar, but it should have also found all the classes in the FastClasspathScanner jar, since it found that jar on the classpath. But not only does it not list the files in either of those jars, it doesn't give any indication as to why (e.g. if the files are not valid zipfiles, there should be something in the log stating that).

This might be something unique to Mac OS X, since I haven't seen this before, and I don't think a lot of people are using FastClasspathScanner on Mac OS X. I don't have a Mac OS X machine available to test this on. Is there some way you could please step through the scanning process in a debugger to see what is happening? You can set a breakpoint in the constructor of io.github.lukehutch.fastclasspathscanner.scanner.ClasspathElementZip , and also at the top of the method scanZipFile() in that same class. If you look at the parameters passed in, you will be able to see when scanning reaches the problematic zipfiles.

Please let me know what you find. Thanks!


Yunior Betancourt

unread,
Jul 5, 2018, 5:34:46 PM7/5/18
to FastClasspathScanner-Users
I scrubbed data from the log, but didn't remove anything. I'll debug through it and see what is going on.

Yunior Betancourt

unread,
Jul 6, 2018, 11:19:12 AM7/6/18
to FastClasspathScanner-Users
I found a couple of interesting behaviors after looking into the issue. If I start the scan without a scanSpec eg. `new FastClasspathScanner()` none of the classes are found.  If I pass in a package name e.g `new FastClasspathScanner("com.foo")` no classes are found even though there are classes under that package name. While debugging into the issue in `scanZipFile()` I found that what is happening is that these classes are getting skipped in the first condition of the code below

// Class can only be scanned if it's within a whitelisted path subtree, or if it is a classfile that has
            // been specifically-whitelisted
            if (parentMatchStatus != ScanSpecPathMatch.HAS_WHITELISTED_PATH_PREFIX
                    && parentMatchStatus != ScanSpecPathMatch.AT_WHITELISTED_PATH
                    && (parentMatchStatus != ScanSpecPathMatch.AT_WHITELISTED_CLASS_PACKAGE
                            || !scanSpec.isSpecificallyWhitelistedClass(relativePath))) {
                continue;
            }

Tracing back to where the parentmatchStatus gets set I found that there is a discrepancy between the package name and the path found in the jar file. While I am filtering by `com.foo` the jar has those classes under the path `BOOT-INF/classes/com.foo/classA`. Under ScanSpec.java the last condition doesn't match because of the path difference and thus returns `ScanSpecPathMatch.NOT_WITHIN_WHITELISTED_PATH` as a result (See code snippet below for that code)
/**
 * Returns true if the given directory path is a descendant of a blacklisted path, or an ancestor or descendant
 * of a whitelisted path. The path should end in "/".
 */
ScanSpecPathMatch dirWhitelistMatchStatus(final String relativePath) {
    ....
    if (whitelistedPathPrefixes.contains(relativePath) || whitelistedPathsNonRecursive.contains(relativePath)) {
        // Reached a whitelisted path
        return ScanSpecPathMatch.AT_WHITELISTED_PATH;
    }
.......
// Not in whitelisted path
        return ScanSpecPathMatch.NOT_WITHIN_WHITELISTED_PATH;
    }

If I set the scanSpec to "BOOT-INF/classes/com/foo the all the classes are found but then I get another issue in the logs as shown below.

2018-07-06T11:07:27.512-0400    FastClasspathScanner    -- Scanning filenames within classpath elements
2018-07-06T11:07:27.512-0400    FastClasspathScanner    ---- Scanning jarfile classpath entry /target/externalApp.jar (took 13.079917 sec)
2018-07-06T11:07:38.495-0400    FastClasspathScanner    ------ Found whitelisted file: BOOT-INF/classes/com/foo/someClass.class
...
2018-07-06T11:07:40.632-0400    FastClasspathScanner    -- Parsing classfile jar:file:/target/externalApp.jar!/BOOT-INF/classes/com/foo/someClass.class (took 0.000113 sec)
2018-07-06T11:07:40.633-0400    FastClasspathScanner    ---- Class com.foo.somaClass is at incorrect relative path BOOT-INF/classes/com/foo/someClass.class -- ignoring
2018-07-06T11:07:40.635-0400    FastClasspathScanner    Building class graph (took 0.006411 sec)
2018-07-06T11:07:40.643-0400    FastClasspathScanner    Completed scan (took 64.325374 sec)

On Thursday, July 5, 2018 at 5:13:39 PM UTC-4, Luke Hutchison wrote:

Luke Hutchison

unread,
Jul 6, 2018, 6:40:22 PM7/6/18
to Yunior Betancourt, FastClasspathScanner-Users
On Fri, Jul 6, 2018 at 2:53 PM Yunior Betancourt <yuni...@gmail.com> wrote:
I uploaded a simplified version of what I have locally to show the issue that I am facing. Here is the git url for the project. I have two maven apps, one is a simple spring boot app that has a class in it called SomeClass. This app will be packaged as externalApp jar. The second folder is the scanner code that loads the jar. I included a test asserting that at least two classes are matched. The only thing that needs to be updated to run the sample is the jar path in the scanner project (Line 19 in the ScannerMain.java). I don't think this is a OS X issue and you should be able to reproduce it. I am more than happy to keep providing info from my sample, but I think it would help if you can access the code.

Thanks, this was super helpful, and the root of the problem is actually pretty interesting...

The first thing I looked at was the manifest file, to see if there was any indication of the package root, and it has these two entries:

Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/

Then Spring-Boot itself is rooted at "org/" in the jar. It reads these two properties to set its own classpath. I will add some special case code to look for these properties in future, so that you don't need to add the "!/BOOT-INF/classes" suffix to the classpath entry. That will solve the package root issue.

However, then there's the issue of FCS not being able to load the class. In fact, you won't be able to load the class yourself either, by calling Class.forName(className, true, classLoader). The reason is that Java can't handle package roots anywhere other than the root of the jar either. Spring-Boot gets around that by implementing its own classloader.

What I'll probably do is check if the ClassLoader for the jar is simply a URLClassLoader rather than a LaunchedUrlClassLoader (Spring-Boot's classloader), and if it's a regular URLClassLoader, I will try automatically instantiating LaunchedUrlClassLoader to create a new Spring-Boot classloader for the jar.

Will let you know when I get this sorted out. Thanks!


Luke Hutchison

unread,
Jul 6, 2018, 7:20:41 PM7/6/18
to Yunior Betancourt, FastClasspathScanner-Users
I filed an issue for this -- please continue the discussion for this issue on GitHub. Hopefully I'll have a fix soon: https://github.com/lukehutch/fast-classpath-scanner/issues/209

Luke Hutchison

unread,
Jul 8, 2018, 9:28:40 AM7/8/18
to Yunior Betancourt, FastClasspathScanner-Users
This was complicated to fix, but the fix has been released in version 3.1.7.  See the related bug report #209 for information.

Thank you Yunior for this bug report!

Yunior Betancourt

unread,
Jul 8, 2018, 11:12:55 AM7/8/18
to Luke Hutchison, FastClasspathScanner-Users
Awesome, thanks!
Reply all
Reply to author
Forward
0 new messages