classgraph: Class loading is broken with Spring Boot's DevTools again.
Hello Luke,
Sadly #331 introduced a regression of #267.
That became apparent in a change of Neo4j-OGM where we now rely on ClassGraph being able to find scanned classes.
Find attached a reproducer:
try(ScanResult r = new ClassGraph()
.ignoreClassVisibility()
.whitelistPackages("com.example.gh729.domain")
.scan()) {
for(ClassInfo classInfo : r.getAllClasses()) {
if("com.example.gh729.domain.SomeClass".equals(classInfo.getName())) {
SomeClass f = (SomeClass) classInfo.loadClass().getConstructor().newInstance();
}
}
}
This works in 4.8.17 and starts to fail in 4.8.19 again (as before my contribution).
This is the expected order of class loaders withorg.springframework.boot.devtools.restart.classloader.RestartClassLoader
present
This is now what I get in 4.8.19+
Both screenshots from debugging into io.github.classgraph.ClassGraphClassLoader
and displaying the order of class loaders used.
Find the reproducer attached. Open in your IDE and run Gh729Application
.
Related OGM ticket is https://github.com/neo4j/neo4j-ogm/issues/729
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (15 by maintainers)
Commits related to this issue
- Respect parent-last classloading (#396) — committed to classgraph/classgraph by lukehutch 4 years ago
- Make some further simplifications for the Restart classloader (#396) — committed to classgraph/classgraph by lukehutch 4 years ago
Actually now that I understand the Restart classloader better, I made some further cleanups to simplify the
ClassLoaderHandler
in the last commit. Please check also that 4.8.61-SNAPSHOT (the git master version) works for you in addition to 4.8.60. (The master version should also work fine.)Great work, Luke! I can confirm both 4.8.60 and 4.8.61-SNAPSHOT works.