JDK-6508599 : 5.1.9: No unchecked conversion for array types
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2006-12-29
  • Updated: 2014-04-10
  • Resolved: 2011-07-21
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.

To download the current JDK release, click here.
JDK 7
7 rcFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
The JLS does not define unchecked conversion for array types.  The compiler
has this conversion.  See 6507024.

Comments
EVALUATION Considering the example from 6507024: --- interface Result<T> {} <T> void m(Result<T>[] results) { Result<T>[] r = results.getClass().cast(null); } The type of results.getClass() is Class<? extends Result[]>. Consequently the type of results.getClass().cast(null) is the capture of ? extends Result[]. So the question is: is there there an unchecked conversion from the capture of ? extends Result[] to Result<T>[]? --- The capture of Class<? extends Result[]> is Class<#1> where ub(#1)=Result[] and lb(#1)=nulltype. The return type of cast(null) is #1. JLS3 5.1.9 should state that C[] becomes C<T>[] after unchecked conversion. This allows an unchecked conversion from #1 (morally, "Result[]") to Result<T>[]. Also, unchecked conversion applies only to raw types, and JLS3 technically does not allow array types to be raw. 4.8 should say: "More precisely, a raw type is defined to be one of: - The reference type that is formed by taking the name of a generic type declaration without any accompanying actual type parameters. - An array type whose element type is a raw reference type. - A non-static..."
26-09-2007