United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 2213800 Inference producing null type argument
2213800 : Inference producing null type argument

Details
Type:
Backport
Submit Date:
2011-09-06
Status:
Closed
Updated Date:
2011-11-28
Project Name:
JDK
Resolved Date:
2011-11-28
Component:
tools
OS:
Sub-Component:
javac
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
Fixed Versions:
7u4

Related Reports
Backport:

Sub Tasks

Description
                                    

Comments
SUGGESTED FIX

http://hg.openjdk.java.net/jdk7u/jdk7u-dev/langtools/rev/8031a8112618
                                     
2011-10-15
EVALUATION

There are two problems here:

1) javac's implementation of 15.12.2.7 ends up adding 'nulltype' as upper bound of inference variables

2) javac's implementation of 15.12.2.8, becauase of constraint propagation, can end up inferring 'nulltype' for a given type-variable.

Fixing (1) will be more complete, but also more risky, as it will introduce subtle overload resolution differences. Fixing only (2) will be less risky, as the overload resolution process will be overall still compliant with what's available in the JDK 7 branch.
                                     
2011-09-15
SUGGESTED FIX

A fix for problem (2) [see evaluation] is the following:

--- old/src/share/classes/com/sun/tools/javac/comp/Infer.java	2011-09-07 12:52:52.080720015 +0100
+++ new/src/share/classes/com/sun/tools/javac/comp/Infer.java	2011-09-07 12:52:51.948682136 +0100
@@ -248,6 +248,13 @@
             return !t.isErroneous();
         }
     };
+    
+    private Filter<Type> botFilter = new Filter<Type>() {
+        @Override
+        public boolean accepts(Type t) {
+            return t.tag != BOT;
+        }
+    };
 
     /** Instantiate undetermined type variable to the lub of all its lower bounds.
      *  Throw a NoInstanceException if this not possible.
@@ -470,7 +477,8 @@
                         UndetVar uv = (UndetVar)t;
                         if (uv.qtype == tv) {
                             switch (ck) {
-                                case EXTENDS: return uv.hibounds.appendList(types.subst(types.getBounds(tv), all_tvars, inferredTypes));
+                                case EXTENDS: return Type.filter(uv.hibounds, botFilter)
+                                        .appendList(types.subst(types.getBounds(tv), all_tvars, inferredTypes));
                                 case SUPER: return uv.lobounds;
                                 case EQUAL: return uv.inst != null ? List.of(uv.inst) : List.<Type>nil();
                             }
--- old/test/tools/javac/Diagnostics/6862608/T6862608a.out	2011-09-07 12:52:52.536708693 +0100
+++ new/test/tools/javac/Diagnostics/6862608/T6862608a.out	2011-09-07 12:52:52.411688328 +0100
@@ -1,3 +1,3 @@
                                     
2011-09-15



Hardware and Software, Engineered to Work Together