JDK-5065215 : javac reports unnecessary unchecked warning
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2004-06-18
  • Updated: 2005-12-30
  • Resolved: 2005-09-26
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 6
6Resolved
Related Reports
Duplicate :  
Description
See
http://forum.java.sun.com/thread.jsp?forum=316&thread=530883&tstart=0&trange=50

Because arrays are covariant, there should be no unchecked warning in the
following code.  Removing the cast causes the warning to go away.

==========$ cat X.java
class X {
    static <T, U extends T> T[] cast(U[] a) { return (T[]) a; }
}
==========$ javac X.java -Xlint
X.java:2: warning: [unchecked] unchecked cast
found   : U[]
required: T[]
    static <T, U extends T> T[] cast(U[] a) { return (T[]) a; }
                                                           ^
1 warning
==========$

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon mustang
08-09-2004

EVALUATION JLS3 says: A cast from a type S to a parameterized type T is unchecked unless at least one of the following conditions hold: * S <: T. Since U[] <: T[] this is a bug. ###@###.### 2004-06-18
18-06-2004