Thu, 27 Aug 2009 11:08:27 -0700
6875336: some tests should use /nodynamiccopyright/
Reviewed-by: darcy
1 import java.util.List;
3 /*
4 * @test /nodynamiccopyright/
5 * @bug 6843077
6 * @summary test that compiler doesn't warn about annotated redundant casts
7 * @author Mahmood Ali
8 * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics -source 1.7 LintCast.java
9 */
10 class LintCast {
11 void unparameterized() {
12 String s = "m";
13 String s1 = (String)s;
14 String s2 = (@A String)s;
15 }
17 void parameterized() {
18 List<String> l = null;
19 List<String> l1 = (List<String>)l;
20 List<String> l2 = (List<@A String>)l;
21 }
23 void array() {
24 int @A [] a = null;
25 int[] a1 = (int[])a;
26 int[] a2 = (int @A [])a;
27 }
29 void sameAnnotations() {
30 @A String annotated = null;
31 String unannotated = null;
33 // compiler ignore annotated casts even if redundant
34 @A String anno1 = (@A String)annotated;
36 // warn if redundant without an annotation
37 String anno2 = (String)annotated;
38 String unanno2 = (String)unannotated;
39 }
40 }
42 @interface A { }