1 /*
2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /**
25  * @test
26  * @bug 8029017
27  * @summary sanity testing of ElementType validation for repeating annotations
28  * @compile TypeUseTarget.java
29  */
30 
31 import java.lang.annotation.*;
32 
33 public class TypeUseTarget {}
34 
35 
36 // Case 1:
37 @Target({
38     ElementType.TYPE_USE,
39 })
40 @Repeatable(Case1Container.class)
41 @interface Case1 {}
42 
43 @Target({
44     ElementType.ANNOTATION_TYPE,
45     ElementType.TYPE,
46     ElementType.TYPE_USE,
47     ElementType.TYPE_PARAMETER,
48 })
49 @interface Case1Container {
value()50   Case1[] value();
51 }
52 
53 
54 // Case 2:
55 @Target({
56     ElementType.TYPE_USE,
57 })
58 @Repeatable(Case2Container.class)
59 @interface Case2 {}
60 
61 @Target({
62     ElementType.ANNOTATION_TYPE,
63     ElementType.TYPE,
64     ElementType.TYPE_USE,
65 })
66 @interface Case2Container {
value()67   Case2[] value();
68 }
69 
70 
71 // Case 3:
72 @Target({
73     ElementType.TYPE_USE,
74 })
75 @Repeatable(Case3Container.class)
76 @interface Case3 {}
77 
78 @Target({
79     ElementType.ANNOTATION_TYPE,
80     ElementType.TYPE,
81 })
82 @interface Case3Container {
value()83   Case3[] value();
84 }
85 
86 
87 // Case 4:
88 @Target({
89     ElementType.TYPE_USE,
90 })
91 @Repeatable(Case4Container.class)
92 @interface Case4 {}
93 
94 @Target({
95     ElementType.ANNOTATION_TYPE,
96 })
97 @interface Case4Container {
value()98   Case4[] value();
99 }
100 
101 
102 // Case 5:
103 @Target({
104     ElementType.TYPE_USE,
105 })
106 @Repeatable(Case5Container.class)
107 @interface Case5 {}
108 
109 @Target({
110     ElementType.TYPE,
111 })
112 @interface Case5Container {
value()113   Case5[] value();
114 }
115 
116 
117 // Case 6:
118 @Target({
119     ElementType.TYPE_USE,
120 })
121 @Repeatable(Case6Container.class)
122 @interface Case6 {}
123 
124 @Target({
125     ElementType.TYPE_PARAMETER,
126 })
127 @interface Case6Container {
value()128   Case6[] value();
129 }
130