-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
7, 8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
public static <T extends List> T newList() {
return null;
}
public static void main(String[] args) {
String s = newList();
}
following code works fine while it should not compile.
0: invokestatic #4 // Method newList:()Ljava/util/List;
3: checkcast #5 // class java/lang/String
the type is inferred correctly but the assignment of a List to String is permitted.
Only happens to interfaces. changing to a concrete class no longer compiles.
REGRESSION. Last worked in version 6u45
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
public static <T extends List> T newList() {
return null;
}
public static void main(String[] args) {
String s = newList();
}
following code works fine while it should not compile.
0: invokestatic #4 // Method newList:()Ljava/util/List;
3: checkcast #5 // class java/lang/String
the type is inferred correctly but the assignment of a List to String is permitted.
Only happens to interfaces. changing to a concrete class no longer compiles.
REGRESSION. Last worked in version 6u45
REPRODUCIBILITY :
This bug can be reproduced always.
- relates to
-
JDK-7120669 4.9: Clarify well-formedness for intersection types & bounded type variables
- Open