BadAnnotationRegressionTest.java revision 4232:01789743ec58
1/* @test /nodynamiccopyright/
2 * @bug 8182747
3 * @summary javac crashes on bad annotation value
4 * @compile/fail/ref=BadAnnotationRegressionTest.out -XDrawDiagnostics BadAnnotationRegressionTest.java
5 */
6
7class BadAnnotationRegressionTest {
8    @interface ClassAnno {
9        Class<?> value();
10    }
11
12    @interface ArrayAnno {
13        int[] value();
14    }
15
16    @interface PrimitiveAnno {
17        int value();
18    }
19
20    @interface StringAnno {
21        String value();
22    }
23
24    enum E {
25        A,
26        B,
27    }
28
29    @interface EnumAnno {
30        E value();
31    }
32
33    static final Class<?> c = Object.class;
34    static final int i = 0;
35    static final int[] arr = new int[] { 1, 2, 3 };
36    static final E a = E.A;
37    static final String s = "";
38
39    @ClassAnno(c)     // error
40    @PrimitiveAnno(i) // ok
41    @ArrayAnno(arr)   // error
42    @EnumAnno(a)      // error
43    @StringAnno(s)    //ok
44    void testAnno() {}
45}
46