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