United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7086601 Error message bug: cause for method mismatch is 'null'
JDK-7086601 : Error message bug: cause for method mismatch is 'null'

Details
Type:
Bug
Submit Date:
2011-09-02
Status:
Closed
Updated Date:
2012-02-24
Project Name:
JDK
Resolved Date:
2012-02-24
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
Given a method invocation that won't match either of two candidates, I'm getting an error message that prints 'null' where a useful description of the mismatch should go.

Code:
public class CauseError {
<S> Iterable<S> glb(Iterable<? super S> s1, Iterable<? super S> s2) { return null; }
<T> Iterable<T> glb(Iterable<? super T> t) { return null; }

CauseError() {
 glb((Iterable<String>) null, (Iterable<Integer>) null);
}

}

Message:

CauseError.java:6: error: no suitable method found for glb(Iterable<String>,Iterable<Integer>)
 glb((Iterable<String>) null, (Iterable<Integer>) null);
 ^
    method CauseError.<T>glb(Iterable<? super T>) is not applicable
      (cannot instantiate from arguments because actual and formal argument lists differ in length)
    method CauseError.<S>glb(Iterable<? super S>,Iterable<? super S>) is not applicable
      (null) <<<<<<<<<< (SHOULD NOT BE NULL)
  where T,S are type-variables:
    T extends Object declared in method <T>glb(Iterable<? super T>)
    S extends Object declared in method <S>glb(Iterable<? super S>,Iterable<? super S>)

Commenting out the other declaration produces a more useful message:

CauseError.java:6: error: method glb in class CauseError cannot be applied to given types
 glb((Iterable<String>) null, (Iterable<Integer>) null);
 ^
  required: Iterable<? super S>,Iterable<? super S>
  found: Iterable<String>,Iterable<Integer>
  where S is a type-variable:
    S extends Object declared in method <S>glb(Iterable<? super S>,Iterable<? super S>)

                                    

Comments
SUGGESTED FIX

A webrev of this fix is available at the following URL:
http://hg.openjdk.java.net/jdk8/tl/langtools/rev/3a2200681d69
                                     
2011-09-13
EVALUATION

The code in Infer.minimizeInst doesn't generate any explanation diagnostics in case lub() result is incompatible with the inference variable's upper bounds. This lead to a method resolution diagnostic that has a 'null' in its explanation field.
                                     
2011-09-13



Hardware and Software, Engineered to Work Together