This might just be a semantic issue, but it is an obvious change in behaviour vs running on Java 8.
We are executing ClassGraph as follows:
ClassGraph().overrideClassLoaders(classLoader)
.ignoreParentClassLoaders()
.enableClassinfo()
.scan()
The classLoader is allowed to be AppClassLoader, and this isn't a problem on Java 8. However, it does cause problems on Java 11. I have tested ClassGraph 4.8.58, 4.8.65 and 4.8.67, and none of them finds any nonSystemModuleRefs, although 4.8.67 does at least find the systemModuleRefs. (To be precise, ClassGraph does find lots of "unnamed modules" on the call-stack, but rejects them all because layer == null.)
We are working around this by doing the following:
ClassGraph().apply {
if (classLoader !== ClassLoader.getSystemClassLoader()) {
overrideClassLoaders(classLoader)
}
}.ignoreParentClassLoaders()
.enableClassinfo()
.scan()
This works because it allows ClasspathFinder to consult the java.class.path system property and so populate the classpathOrder field instead. And to be clear, these are the jars we want to be scanning. We have no need to scan the systemModuleRefs here.
See #382 and #411.
This might just be a semantic issue, but it is an obvious change in behaviour vs running on Java 8.
We are executing ClassGraph as follows:
ClassGraph().overrideClassLoaders(classLoader) .ignoreParentClassLoaders() .enableClassinfo() .scan()The
classLoaderis allowed to beAppClassLoader, and this isn't a problem on Java 8. However, it does cause problems on Java 11. I have tested ClassGraph 4.8.58, 4.8.65 and 4.8.67, and none of them finds anynonSystemModuleRefs, although 4.8.67 does at least find thesystemModuleRefs. (To be precise, ClassGraph does find lots of "unnamed modules" on the call-stack, but rejects them all becauselayer == null.)We are working around this by doing the following:
This works because it allows
ClasspathFinderto consult thejava.class.pathsystem property and so populate theclasspathOrderfield instead. And to be clear, these are the jars we want to be scanning. We have no need to scan thesystemModuleRefshere.See #382 and #411.