Spotbugs: FindUnrelatedTypesInGenericContainer throws IAE on Java 9 ("Not a reference type: <bottom>")

Created on 13 Nov 2017  路  3Comments  路  Source: spotbugs/spotbugs

Reduced my original class causing this error down to this MCVE:

package com.example;
import java.util.Map;

public class CrashesAnalysis {

    String literalOK(Map<String, String> map) {
        return map.get("const");
    }

    String refOK(Map<String, String> map, String key) {
        return map.get(key);
    }

    String nonConstConcatFails(Map<String, String> map, String key) {
        return map.get(key + "const");
    }
}
Throws:
Scanning archives (149 / 149)
2 analysis passes to perform
Pass 1: Analyzing classes (338 / 338) - 100% complete
Pass 2: Analyzing classes (138 / 138) - 100% complete
Done with analysis
The following errors occurred during analysis:
  Exception analyzing com.example.CrashesAnalysis using detector edu.umd.cs.findbugs.detect.FindUnrelatedTypesInGenericContainer
    java.lang.IllegalArgumentException: Not a reference type: <bottom>
      At edu.umd.cs.findbugs.ba.generic.GenericUtilities.getTypeCategory(GenericUtilities.java:200)
      At edu.umd.cs.findbugs.detect.FindUnrelatedTypesInGenericContainer.compareTypes(FindUnrelatedTypesInGenericContainer.java:739)
      At edu.umd.cs.findbugs.detect.FindUnrelatedTypesInGenericContainer.analyzeMethod(FindUnrelatedTypesInGenericContainer.java:582)
      At edu.umd.cs.findbugs.detect.FindUnrelatedTypesInGenericContainer.visitClassContext(FindUnrelatedTypesInGenericContainer.java:259)
      At edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)
      At edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1079)
      At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:280)
      At com.github.spotbugs.internal.spotbugs.SpotBugsExecuter.runSpotbugs(SpotBugsExecuter.java:23)

Environment:

SpotBugs 3.1.0
SpotBugs Gradle plugin 1.6.0

java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

------------------------------------------------------------
Gradle 4.2.1
------------------------------------------------------------

Build time:   2017-10-02 15:36:21 UTC
Revision:     a88ebd6be7840c2e59ae4782eb0f27fbe3405ddf

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          9 (Oracle Corporation 9+181)
OS:           Windows 10 10.0 amd64

Note: there is no IAE thrown when compiled using JDK 8 (u152). I strongly expect it relates to JDK 9 javac using invokedynamic for string concatenation, whereas JDK 8 uses a StringBuilder. If I replace the concatenation with a single String literal, or the key reference, then the error no longer occurs on JDK 9.

Java-9 bug

All 3 comments

@iloveeclipse or @KengoTODA - finally tracked this down with a fix & test case (PR #727). Please kindly review.

Confirmed fixed using Java 10.0.2 and Spotbugs release 3.1.7 from Maven Central

Was this page helpful?
0 / 5 - 0 ratings