FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
The following program does not compile using javac (but does compile using the eclipse compiler).
public static void main(String... s) {
List<?> l = Arrays.asList(1, 2, 3, 4);
if (l.get(0) instanceof Integer) {
System.out.println((int) l.get(0));
}
}
incompatible types: capture#1 of ? cannot be converted to int
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String... s) {
List<?> l = Arrays.asList(1, 2, 3, 4);
if (l.get(0) instanceof Integer) {
System.out.println((int) l.get(0));
}
}
-> incompatible types: capture#1 of ? cannot be converted to int
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public static void main(String... s) {
List<?> l = Arrays.asList(1, 2, 3, 4);
if (l.get(0) instanceof Integer) {
System.out.println((Integer) l.get(0));
}
}
-> OK ! Just changing from primitive to object