JDK-8144832 : cast conversion fails when converting a type-variable to primitive type
Type:Bug
Component:tools
Sub-Component:javac
Affected Version:7u85,8,9
Priority:P3
Status:Closed
Resolution:Fixed
Submitted:2015-12-07
Updated:2017-01-05
Resolved:2015-12-16
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
The following program is erroneously rejected by javac:
class Test<T> {
public void foo(T valIn){
double val = (double ) valIn;
}
}
Comments
Another test case, from JDK-8168269, this time using capture variables:
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));
}
}