InvalidRepAnnoOnCast.java revision 2900:732890c00534
1/**
2 * @test    /nodynamiccopyright/
3 * @bug     8044196
4 * @summary Make sure repeatable annotations can't be erroneously applied to a cast type
5 * @compile/fail/ref=InvalidRepAnnoOnCast.out -XDrawDiagnostics InvalidRepAnnoOnCast.java
6 */
7
8import java.lang.annotation.*;
9
10class InvalidRepAnnoOnCast {
11
12    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
13    @Repeatable(TC.class)
14    @interface T { int value(); }
15
16    @Target(ElementType.TYPE_PARAMETER)
17    @interface TC { T[] value(); }
18
19    String s = (@T(1) @T(2) String) new Object();
20}
21