author | mcimadamore |
Thu, 05 Mar 2009 17:24:08 +0000 | |
changeset 2218 | a8ec0baae870 |
child 3766 | 7e2df99e9223 |
permissions | -rw-r--r-- |
2218
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
1 |
/* |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
4 |
* |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
8 |
* |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
14 |
* |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
18 |
* |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
21 |
* have any questions. |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
23 |
|
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
24 |
/* |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
26 |
* @author mcimadamore |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
27 |
* @bug 6467183 |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
28 |
* @summary |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
29 |
* @compile/fail/ref=T6467183a.out -Xlint:unchecked -Werror -XDrawDiagnostics T6467183a.java |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
30 |
*/ |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
31 |
|
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
32 |
class T6467183a<T> { |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
33 |
|
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
34 |
class A<S> {} |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
35 |
class B extends A<Integer> {} |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
36 |
class C<X> extends A<X> {} |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
37 |
|
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
38 |
void cast1(B b) { |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
39 |
Object o = (A<T>)b; |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
40 |
} |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
41 |
|
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
42 |
void cast2(B b) { |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
43 |
Object o = (A<? extends Number>)b; |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
44 |
} |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
45 |
|
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
46 |
void cast3(A<Integer> a) { |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
47 |
Object o = (C<? extends Number>)a; |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
48 |
} |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
49 |
|
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
50 |
void cast4(A<Integer> a) { |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
51 |
Object o = (C<? extends Integer>)a; |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
52 |
} |
a8ec0baae870
6467183: javac fails to raise unchecked warning on cast of parameterized generic subclass
mcimadamore
parents:
diff
changeset
|
53 |
} |