mebigfatguy / fb-contrib

a FindBugs/SpotBugs plugin for doing static code analysis for java code bases
http://fb-contrib.sf.net
GNU Lesser General Public License v2.1
157 stars 45 forks source link

BCEL errors with fb-contrib 7.6.4 #470

Closed patric-r closed 6 months ago

patric-r commented 8 months ago

With fb-contrib 7.6.4, we are constantly seeing the following two exceptions:

java.lang.ClassCastException: class org.apache.bcel.classfile.BootstrapMethods cannot be cast to class org.apache.bcel.classfile.Unknown (org.apache.bcel.classfile.BootstrapMethods and org.apache.bcel.classfile.Unknown are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @3d75074c)
    at com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues.getMethodHandle(FunctionalInterfaceIssues.java:412)
    at com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues.sawOpcode(FunctionalInterfaceIssues.java:298)
    at edu.umd.cs.findbugs.visitclass.DismantleBytecode.visit(DismantleBytecode.java:878)
    at edu.umd.cs.findbugs.visitclass.BetterVisitor.visitCode(BetterVisitor.java:218)
    at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitCode(PreorderVisitor.java:250)
    at com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues.visitCode(FunctionalInterfaceIssues.java:193)
    at org.apache.bcel.classfile.Code.accept(Code.java:145)
    at edu.umd.cs.findbugs.visitclass.PreorderVisitor.doVisitMethod(PreorderVisitor.java:322)
    at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitJavaClass(PreorderVisitor.java:404)
    at org.apache.bcel.classfile.JavaClass.accept(JavaClass.java:251)
    at edu.umd.cs.findbugs.BytecodeScanningDetector.visitClassContext(BytecodeScanningDetector.java:38)
    at com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues.visitClassContext(FunctionalInterfaceIssues.java:122)
    at edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)
    at edu.umd.cs.findbugs.FindBugs2.lambda$analyzeApplication$1(FindBugs2.java:1108)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at edu.umd.cs.findbugs.CurrentThreadExecutorService.execute(CurrentThreadExecutorService.java:86)
    at java.base/java.util.concurrent.AbstractExecutorService.invokeAll(AbstractExecutorService.java:247)
    at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1118)
    at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:309)
    at de.tobject.findbugs.builder.FindBugsWorker.runFindBugs(FindBugsWorker.java:314)
    at de.tobject.findbugs.builder.FindBugsWorker.work(FindBugsWorker.java:220)
    at de.tobject.findbugs.builder.FindBugsBuilder$StartedFromBuilderJob.runWithProgress(FindBugsBuilder.java:219)
    at de.tobject.findbugs.FindBugsJob.run(FindBugsJob.java:142)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
java.lang.RuntimeException: Incompatible bcel version, apparently bcel has been upgraded to not use 'Unknown' for 'BootstrapMethods', but uses: BootstrapMethods
    at com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod.getBootstrapMethod(OverlyPermissiveMethod.java:473)
    at com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod.sawOpcode(OverlyPermissiveMethod.java:176)
    at edu.umd.cs.findbugs.visitclass.DismantleBytecode.visit(DismantleBytecode.java:878)
    at edu.umd.cs.findbugs.visitclass.BetterVisitor.visitCode(BetterVisitor.java:218)
    at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitCode(PreorderVisitor.java:250)
    at com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod.visitCode(OverlyPermissiveMethod.java:121)
    at org.apache.bcel.classfile.Code.accept(Code.java:145)
    at edu.umd.cs.findbugs.visitclass.PreorderVisitor.doVisitMethod(PreorderVisitor.java:322)
    at edu.umd.cs.findbugs.visitclass.PreorderVisitor.visitJavaClass(PreorderVisitor.java:404)
    at org.apache.bcel.classfile.JavaClass.accept(JavaClass.java:251)
    at edu.umd.cs.findbugs.BytecodeScanningDetector.visitClassContext(BytecodeScanningDetector.java:38)
    at com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod.visitClassContext(OverlyPermissiveMethod.java:99)
    at edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)
    at edu.umd.cs.findbugs.FindBugs2.lambda$analyzeApplication$1(FindBugs2.java:1108)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at edu.umd.cs.findbugs.CurrentThreadExecutorService.execute(CurrentThreadExecutorService.java:86)
    at java.base/java.util.concurrent.AbstractExecutorService.invokeAll(AbstractExecutorService.java:247)
    at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1118)
    at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:309)
    at de.tobject.findbugs.builder.FindBugsWorker.runFindBugs(FindBugsWorker.java:314)
    at de.tobject.findbugs.builder.FindBugsWorker.work(FindBugsWorker.java:220)
    at de.tobject.findbugs.builder.FindBugsBuilder$StartedFromBuilderJob.runWithProgress(FindBugsBuilder.java:219)
    at de.tobject.findbugs.FindBugsJob.run(FindBugsJob.java:142)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Any help is appreciated.

mebigfatguy commented 6 months ago

i assume you are using > jdk8, if so you should be using spotbugs, with the sb-contrib plugin