Menu

#1415 bcel error constructing methodGen Invalid method signature using lambda and stream api

3.x
closed-rejected
nobody
5
2017-10-22
2015-08-25
vgropp
No

The following exception occurs with findbugs 3.0.1 analysing this code:

public interface HasUniqueKey<Key> {
  Key getInternId();
}

public class Util {
  public static List<Integer> toIntegerList(List<? extends HasUniqueKey<Integer>> entities) {
    return entities.stream().map(m -> m.getInternId()).collect(Collectors.toList());
  }
 }
The following errors occurred during analysis:
  Error constructing methodGen
    org.apache.bcel.classfile.ClassFormatException: Invalid method signature: !+Lde/HasUniqueKey<Ljava/lang/Integer;>;
      At org.apache.bcel.classfile.Utility.typeOfSignature(Utility.java:1012)
      At org.apache.bcel.generic.Type.getType(Type.java:181)
      At org.apache.bcel.generic.MethodGen.<init>(MethodGen.java:258)
      At edu.umd.cs.findbugs.classfile.engine.bcel.MethodGenFactory.analyze(MethodGenFactory.java:90)
      At edu.umd.cs.findbugs.classfile.engine.bcel.MethodGenFactory.analyze(MethodGenFactory.java:41)
      At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.analyzeMethod(AnalysisCache.java:369)
      At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getMethodAnalysis(AnalysisCache.java:322)
      At edu.umd.cs.findbugs.ba.ClassContext.getMethodAnalysis(ClassContext.java:1002)
      At edu.umd.cs.findbugs.ba.ClassContext.getMethodAnalysisNoException(ClassContext.java:976)
      At edu.umd.cs.findbugs.ba.ClassContext.getMethodGen(ClassContext.java:287)
      At edu.umd.cs.findbugs.detect.FindUseOfNonSerializableValue.analyzeMethod(FindUseOfNonSerializableValue.java:126)
      At edu.umd.cs.findbugs.detect.FindUseOfNonSerializableValue.visitClassContext(FindUseOfNonSerializableValue.java:94)
      At edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)
      At edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1089)
      At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:283)
      At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:402)
      At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1200)

using this implementation the analysis is running without an error:

  public static List<Integer> toIntegerList(List<? extends HasUniqueKey<Integer>> entities) {
    return entities.stream().map((HasUniqueKey<Integer> m) -> m.getInternId()).collect(Collectors.toList());
  }

I tried using bcel-6.0 (final) because i think its an upstream bug but failed running this version against findbugs master.

Discussion

  • Jonas

    Jonas - 2015-11-04

    Note that this bug only occurs if the class files have been compiled using eclipse's compiler, as contained in current eclipse 'mars' (4.5). It does not occur if the class files are compiled using javac from jdk 1.8.0_66. It also didn't occur using the compiler of eclipse 4.4.2.
    Note that this still isn't a compiler bug, as the code compiled by eclipse mars (4.5) still runs fine.

     
  • Josef Freundorfer

    Same problem here, using findbugs-maven-plugin version 3.0.4 in combination with Tycho 1.0.0 having Eclipse-Compiler activated.

     
  • Andrey Loskutov

    Andrey Loskutov - 2017-10-22
    • Status: open --> closed-rejected
     

Log in to post a comment.