jjg@309: import java.util.List; jjg@309: jjg@309: /* jjg@384: * @test /nodynamiccopyright/ jjg@309: * @bug 6843077 jjg@309: * @summary test that compiler doesn't warn about annotated redundant casts jjg@309: * @author Mahmood Ali jjg@309: * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics -source 1.7 LintCast.java jjg@309: */ jjg@309: class LintCast { jjg@309: void unparameterized() { jjg@309: String s = "m"; jjg@309: String s1 = (String)s; jjg@309: String s2 = (@A String)s; jjg@309: } jjg@309: jjg@309: void parameterized() { jjg@309: List l = null; jjg@309: List l1 = (List)l; jjg@309: List l2 = (List<@A String>)l; jjg@309: } jjg@309: jjg@309: void array() { jjg@309: int @A [] a = null; jjg@309: int[] a1 = (int[])a; jjg@309: int[] a2 = (int @A [])a; jjg@309: } jjg@309: jjg@309: void sameAnnotations() { jjg@309: @A String annotated = null; jjg@309: String unannotated = null; jjg@309: jjg@309: // compiler ignore annotated casts even if redundant jjg@309: @A String anno1 = (@A String)annotated; jjg@309: jjg@309: // warn if redundant without an annotation jjg@309: String anno2 = (String)annotated; jjg@309: String unanno2 = (String)unannotated; jjg@309: } jjg@309: } jjg@309: jjg@309: @interface A { }