JDK-6995200 : JDK 7 compiler crashes when type-variable is inferred from expected primitive type
Type:Bug
Component:tools
Sub-Component:javac
Affected Version:6u21,7
Priority:P2
Status:Closed
Resolution:Fixed
OS:generic,windows_xp,windows_7
CPU:unknown,x86
Submitted:2010-10-27
Updated:2014-05-06
Resolved:2011-03-08
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 crashes javac:
class X {
public static <T> T getValue() {
return null;
}
public void testGenerics(Comparable<String> s) {
int i = getValue();
}
}
Comments
SUGGESTED FIX
A webrev of this fix is available at the following URL:
http://hg.openjdk.java.net/jdk7/tl/langtools/rev/2536dedd897e
23-11-2010
EVALUATION
This bug is related to 6785114. Since the expected type is a primitive type, javac tries to compute glb(int,Object) which is incorrect. As described in the evaluation of 6785114, javac should compute glb(box(int),Object) = glb(Integer,Object) = Integer.