NPE in Type.UndetVar.debugString()

B. Blaser bsrbnd at gmail.com
Sat Sep 16 13:54:57 UTC 2017


Hi,

When working on [1], I saw that "Type.UndetVar.debugString()"
sometimes throws a NPE when called from within "UndetVar", for example
in "addBound()" as here under, which is annoying...

Could someone eventually push the following harmless fix to the amber
and jdk10 repositories?

This might be really helpful when debugging...

Thanks,
Bernard

[1] http://mail.openjdk.java.net/pipermail/amber-dev/2017-September/002061.html

diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java
b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java
@@ -1974,7 +1974,7 @@
             }
             for (InferenceBound bound: InferenceBound.values()) {
                 List<Type> aboundList = bounds.get(bound);
-                if (aboundList.size() > 0) {
+                if (aboundList != null && aboundList.size() > 0) {
                     result += bound + " = " + aboundList + '\n';
                 }
             }
@@ -2112,6 +2112,7 @@
                 bounds.put(ib, prevBounds.prepend(bound2));
                 notifyBoundChange(ib, bound2, false);
             }
+//System.err.println("debug: " + debugString());
         }
         //where
             TypeMapping<Void> toTypeVarMap = new
StructuralTypeMapping<Void>() {


More information about the amber-dev mailing list