Sat, 13 Apr 2013 12:25:44 +0100
8010659: Javac Crashes while building OpenJFX
Reviewed-by: jjg
Contributed-by: maurizio.cimadamore@oracle.com
1 import java.lang.annotation.*;
2 import java.util.List;
4 /*
5 * @test /nodynamiccopyright/
6 * @bug 6843077 8006775
7 * @summary test that compiler doesn't warn about annotated redundant casts
8 * @author Mahmood Ali
9 * @author Werner Dietl
10 * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics LintCast.java
11 */
12 class LintCast {
13 void unparameterized() {
14 String s = "m";
15 String s1 = (String)s;
16 String s2 = (@A String)s;
17 }
19 void parameterized() {
20 List<String> l = null;
21 List<String> l1 = (List<String>)l;
22 List<String> l2 = (List<@A String>)l;
23 }
25 void array() {
26 int @A [] a = null;
27 int[] a1 = (int[])a;
28 int[] a2 = (int @A [])a;
29 }
31 void sameAnnotations() {
32 @A String annotated = null;
33 String unannotated = null;
35 // compiler ignore annotated casts even if redundant
36 @A String anno1 = (@A String)annotated;
38 // warn if redundant without an annotation
39 String anno2 = (String)annotated;
40 String unanno2 = (String)unannotated;
41 }
43 void more() {
44 Object @A [] a = null;
45 Object[] a1 = (Object[])a;
46 Object[] a2 = (Object @A [])a;
48 @A List<String> l3 = null;
49 List<String> l4 = (List<String>)l3;
50 List<String> l5 = (@A List<String>)l3;
52 List<@A String> l6 = null;
53 List<String> l7 = (List<String>)l6;
54 List<String> l8 = (List<@A String>)l6;
56 @A Object o = null;
57 Object o1 = (Object)o;
58 Object o2 = (@A Object)o;
60 Outer. @A Inner oi = null;
61 Outer.Inner oi1 = (Outer.Inner)oi;
62 Outer.Inner oi2 = (Outer. @A Inner)oi;
63 }
65 class Outer { class Inner {} }
66 }
68 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
69 @interface A { }