views:

93

answers:

1

I have a mixed scala/java project - mostly java. I would like to use Findbugs on my java code, but the scala classes are giving it trouble. So I'd like to exclude them from Findbugs. So far I've tried listing the scala classes in an exclude filter, but that's not helping. I'm using the maven codehaus findbugs plugin version 2.3.1.

The exceptions I'm getting mostly take this form:

Exception analyzing some.scala.Class using detector edu.umd.cs.findbugs.detect.FindUnrelatedTypesInGenericContainer
  java.lang.NullPointerException
    At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM$1$2.visitEnd(ClassParserUsingASM.java:319)
    At org.objectweb.asm.ClassReader.accept(Unknown Source)
    At edu.umd.cs.findbugs.asm.FBClassReader.accept(FBClassReader.java:44)
    At org.objectweb.asm.ClassReader.accept(Unknown Source)
    At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:93)
    At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:414)
    At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:65)
    At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:39)
    At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:214)
    At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:581)
    At edu.umd.cs.findbugs.ba.AnalysisCacheToAnalysisContextAdapter.setAppClassList(AnalysisCacheToAnalysisContextAdapter.java:319)
    At edu.umd.cs.findbugs.FindBugs2.createAnalysisContext(FindBugs2.java:785)
    At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:187)
    At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:348)
    At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1057)
+2  A: 

Not really a solution, but FindBugs should work for Scala generated class files as well, so I'd suggest to report these errors to the FindBugs team. Of course the analysis of FindBugs might be not very helpful for Scala classes in most cases (because of the heavy compiler magic), but at least FindBugs shouldn't crash. I hope that sooner or later FindBugs will be extended to give Scala classes a special treatment (but that won't happen if nobody complains :-)

Landei
Indeed, the bug has been fixed in findbugs trunk: http://code.google.com/p/findbugs/source/detail?r=12121 I'm not sure if there's a way to make the findbugs maven plugin use a trunk build of findbugs though.
Geoff Reedy
@Geoff Reedy Thanks! I had to apply the fix to the 1.3.9 code myself, but it seems to have made findbugs happy. Hopefully, findbugs 2.0 will be out soon.
sblundy