| 
 Duplicate :   
 | 
|
| 
 Relates :   
 | 
|
| 
 Relates :   
 | 
|
| 
 Relates :   
 | 
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
javac rejects the following apparently incorrect snippet of code
  <T> void sort(T[] a, Comparator<? super T> c) { return null; }
  Enum[] ea = null;
  Comparator<Enum<?>> comp = null;
  { sort(ea, comp); }
I tried the following to see which way the subtype relations run between Enum and Enum<?>
  List<? extends Enum<?>> t1 = null;
  List<? extends Enum> t2 = null;
  // { t1 = t2; } // error here indicates Enum is not a subtype of Enum<?>
  { t2 = t1; } // allowed, showing Enum<?> is a subtype of Enum
javac appears to infer Enum in the call to sort(...), but that should lead to an error based on the subtyping relations.  javac agrees, rejecting
  { this.<Enum>sort(ea, comp); }
The fact that javac does not check the call after inferring the type argument is a bug.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the enclosed test case, which should fail
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Bound.java:13: <T>sort(T[],java.util.Comparator<? super T>) in Bound cannot be applied to (java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>)
  { this.<Enum>sort(ea, comp); } // yet javac accepts this code, inferring T=Enum
    ^
1 error
ACTUAL -
compile without error
ERROR MESSAGES/STACK TRACES THAT OCCUR :
error messages missing
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
class Bound {
  List<? extends Enum<?>> t1 = null;
  List<? extends Enum> t2 = null;
  // { t1 = t2; } // error here indicates Enum is not a subtype of Enum<?>
  { t2 = t1; }
  <T> T sort(T[] a, Comparator<? super T> c) { return null; }
  Enum[] ea = null;
  Comparator<Enum<?>> comp = null;
  { this.sort(ea, comp); } // yet javac accepts this code, inferring T=Enum
                           // suggesting Enum<?> is a supertype of Enum.
}
---------- END SOURCE ----------
  |