findbugs-slf4j
findbugs-slf4j copied to clipboard
Exception while looking for class java/lang/Thread$UncaughtExceptionHandler
Under Java 9, both findbugs and spotbugs seem to fail when running the findbugs-slf4j checks on our usage of Thread.UncaughtExceptionHandler with the following:
private static final UncaughtExceptionHandler uncaughtExceptionHandler =
(t, e) -> LOG.error(format("Unhandled thread exception %s: %s", t.getName(), e.getMessage()), e);
The exception is:
[java] Exception in thread "main" java.lang.AssertionError: java.lang.ClassNotFoundException: Exception while looking for class java/lang/Thread$UncaughtExceptionHandler
[java] at jp.skypencil.findbugs.slf4j.IllegalPassedClassDetector.memorizeResultOfGetClassMethod(IllegalPassedClassDetector.java:64)
[java] at jp.skypencil.findbugs.slf4j.IllegalPassedClassDetector.afterOpcode(IllegalPassedClassDetector.java:32)
[java] at edu.umd.cs.findbugs.visitclass.DismantleBytecode.visit(DismantleBytecode.java:884)
[java] at edu.umd.cs.findbugs.visitclass.BetterVisitor.visitCode(BetterVisitor.java:218)
[java] at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitCode(PreorderVisitor.java:243)
[java] at edu.umd.cs.findbugs.bcel.OpcodeStackDetector.visitCode(OpcodeStackDetector.java:65)
[java] at org.apache.bcel.classfile.Code.accept(Code.java:132)
[java] at edu.umd.cs.findbugs.visitclass.PreorderVisitor.doVisitMethod(PreorderVisitor.java:315)
[java] at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitJavaClass(PreorderVisitor.java:403)
Actually - this seems to be triggering under Java 8 as well.
So... thumbs up - what does that mean? Is this a known issue? Any idea how it could be resolved ( is it a bug in the plugin, or possibly my project? )?
I've been able to reliably reproduce this with a parallel build and disabling spotbugs forking.
mvn clean verify -T 1C -Dspotbugs.fork=false
Caused by: java.lang.AssertionError: java.lang.ClassNotFoundException: Exception while looking for class com/company/project/Service
at jp.skypencil.findbugs.slf4j.IllegalPassedClassDetector.memorizeResultOfGetClassMethod (IllegalPassedClassDetector.java:80)
at jp.skypencil.findbugs.slf4j.IllegalPassedClassDetector.afterOpcode (IllegalPassedClassDetector.java:42)
at edu.umd.cs.findbugs.visitclass.DismantleBytecode.visit (DismantleBytecode.java:884)
1.4.1 has related fix, that stops throwing exception: 042a74c0ff92a505cdcd49920217dbd92ff1658a
But this doesn't solve root problem. I cannot reproduce this issue for now. I guest it is caused by thread unsafety of Apache BCEL.