TypeUseTargetNeg.java revision 2264:0868788af55b
1/** 2 * @test /nodynamiccopyright/ 3 * @bug 8029017 4 * @summary sanity testing of ElementType validation for repeating annotations 5 * @compile/fail/ref=TypeUseTargetNeg.out -XDrawDiagnostics TypeUseTargetNeg.java 6 */ 7 8import java.lang.annotation.*; 9 10public class TypeUseTargetNeg {} 11 12// Case 1: 13@Target({ 14 ElementType.TYPE_USE, 15}) 16@Repeatable(FooContainer.class) 17@interface Foo {} 18 19@Target({ 20 ElementType.ANNOTATION_TYPE, 21 ElementType.TYPE, 22 ElementType.TYPE_USE, 23 ElementType.TYPE_PARAMETER, 24 ElementType.FIELD, 25 26}) 27@interface FooContainer { 28 Foo[] value(); 29} 30 31 32// Case 2: 33@Target({ 34 ElementType.TYPE_USE, 35}) 36@Repeatable(BarContainer.class) 37@interface Bar {} 38 39@Target({ 40 ElementType.ANNOTATION_TYPE, 41 ElementType.TYPE, 42 ElementType.TYPE_USE, 43 ElementType.METHOD, 44}) 45@interface BarContainer { 46 Bar[] value(); 47} 48 49 50// Case 3: 51@Target({ 52 ElementType.TYPE_USE, 53}) 54@Repeatable(BazContainer.class) 55@interface Baz {} 56 57@Target({ 58 ElementType.ANNOTATION_TYPE, 59 ElementType.TYPE, 60 ElementType.PARAMETER, 61}) 62@interface BazContainer { 63 Baz[] value(); 64} 65 66 67// Case 4: 68@Target({ 69 ElementType.TYPE_USE, 70}) 71@Repeatable(QuxContainer.class) 72@interface Qux {} 73 74@interface QuxContainer { 75 Qux[] value(); 76} 77 78 79// Case 5: 80@Target({}) 81@Repeatable(QuuxContainer.class) 82@interface Quux {} 83 84@Target({ 85 ElementType.TYPE_PARAMETER, 86}) 87@interface QuuxContainer { 88 Quux[] value(); 89} 90 91// Case 6: 92@Repeatable(QuuuxContainer.class) 93@interface Quuux {} 94 95@Target({ 96 ElementType.TYPE_USE, 97}) 98@interface QuuuxContainer { 99 Quuux[] value(); 100} 101