I have an invocation of FindBugs 3.1.0-RC1 that works fine under JDK8, but under JDK9 I get this:
java.io.IOException: IOException while scanning codebases
at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:285)
at edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:393)
at edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1200)
Caused by: edu.umd.cs.findbugs.classfile.ResourceNotFoundException: Resource not found: java/lang/Object.class
at edu.umd.cs.findbugs.classfile.impl.ClassPathImpl.lookupResource(ClassPathImpl.java:164)
at edu.umd.cs.findbugs.classfile.impl.ClassPathBuilder.build(ClassPathBuilder.java:282)
at edu.umd.cs.findbugs.FindBugs2.buildClassPath(FindBugs2.java:677)
at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:218)
... 2 more
It almost seems like FindBugs is looking at the legacy classpath or rt.jar or something to find this class (which is now located in a module of course), but I'm pretty sure your own testing would have caught such a basic problem. How can I go about investigating this issue?
This is known issue and we handle this in #101.
Simply speaking SpotBugs and many other bytecode manipulating library such as javaassist don't work with jigsaw currently.
In theory we can support it iff we use Module class provided from Java9. It means that we need to compile SpotBugs with JDK9. However we also wants to support Java8 users. Maybe this is possible by MRJAR I hope.
The crudest thing you could do that would work would probably be to probe for java.lang.reflect.Module using Class#forName, and to interact with it using reflection if you manage to find it. You could also speed up the reflective calls to a heavily used method by obtaining a MethodHandle.
@rschmitt Great, thanks for your information!
Is the issue that Spotbugs is not using the jrt file system to locate the system classes? At one point I think Andrey Loskutov has this implemented in FindBugs.
Yep, I did it once for one of the earlier JDK 9 betas: https://github.com/spotbugs/spotbugs/commit/9e10194ad060afc93790a41dd27a2a2daac83500
So this isn't working now? Bad.
Probably due https://bugs.openjdk.java.net/browse/JDK-8169816
Anyway, I've just tried with jdk-9+178_linux-x64 version and spotbugs works out of the box if the JVM is started with --add-modules=ALL-SYSTEM.
I plan to close this one with #271.
Everyone who test Java 9 and SpotBugs should use both in the latest versions, and also add --add-modules=ALL-SYSTEM argument to the JVM to start SpotBugs.
Why is --add-modules=ALL-SYSTEM needed? If this is because of dependences on the EE modules then keep in mind that they have been deprecated-for-removal and will (hopefully) be dropped in the future.
I haven't further investigated this, it worked and I was just happy. May be because of javax namespace of JSR-305 annotations? I have tested from Eclipse, because this is the easiest way for me. May be without both (Eclipse and args) it would also work.
I'm closing this now. Any new issues regarding Java 9 incompatibilities please into new tickets.
Most helpful comment
I'm closing this now. Any new issues regarding Java 9 incompatibilities please into new tickets.