-
Bug
-
Resolution: Duplicate
-
P4
-
5.0
-
generic
-
solaris_8
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
==========$
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
==========$
- duplicates
-
JDK-4916620 legal cast is rejected
- Closed