1/*
2 * Copyright (c) 2009, 2013, 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
24import java.lang.annotation.*;
25import static java.lang.annotation.ElementType.*;
26import static java.lang.annotation.RetentionPolicy.*;
27
28import java.util.*;
29import java.io.*;
30
31/*
32 * @test
33 * @summary compiler accepts all values
34 * @author Mahmood Ali
35 * @author Yuri Gaevsky
36 * @compile TargetTypes.java
37 */
38
39@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface A {}
40@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface B {}
41@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface C {}
42@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface D {}
43@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface E {}
44@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface F {}
45@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface G {}
46@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface H {}
47@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface I {}
48@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface J {}
49@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface K {}
50@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface L {}
51@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface M {}
52@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface N {}
53@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface O {}
54@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface P {}
55@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface Q {}
56@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface R {}
57@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface S {}
58@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface U {}
59@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface V {}
60@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface W {}
61@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface X {}
62@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface Y {}
63@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface Z {}
64@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AA {}
65@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AB {}
66@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AC {}
67@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AD {}
68@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AE {}
69@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AF {}
70@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AG {}
71@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AH {}
72@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AI {}
73@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AJ {}
74
75/** wildcard bound */
76class T0x1C {
77    void m0x1C(List<? extends @A String> lst) {}
78}
79
80/** wildcard bound generic/array */
81class T0x1D<T> {
82    void m0x1D(List<? extends @B List<int[]>> lst) {}
83}
84
85/** typecast */
86class T0x00 {
87    void m0x00(Long l1) {
88        Object l2 = (@C Long) l1;
89    }
90}
91
92/** typecast generic/array */
93class T0x01<T> {
94    void m0x01(List<T> list) {
95        List<T> l = (List<@D T>) list;
96    }
97}
98
99/** instanceof */
100class T0x02 {
101    boolean m0x02(String s) {
102        return (s instanceof @E String);
103    }
104}
105
106/** object creation (new) */
107class T0x04 {
108    void m0x04() {
109        new @F ArrayList<String>();
110    }
111}
112
113/** local variable */
114class T0x08 {
115    void m0x08() {
116      @G String s = null;
117    }
118}
119
120/** method parameter generic/array */
121class T0x0D {
122    void m0x0D(HashMap<@H Object, List<@I List<@J Class>>> s1) {}
123}
124
125/** method receiver */
126class T0x06 {
127    void m0x06(@K T0x06 this) {}
128}
129
130/** method return type generic/array */
131class T0x0B {
132    Class<@L Object> m0x0B() { return null; }
133}
134
135/** field generic/array */
136class T0x0F {
137    HashMap<@M Object, @N Object> c1;
138}
139
140/** method type parameter */
141class T0x20<T, U> {
142    <@O T, @P U> void m0x20() {}
143}
144
145/** class type parameter */
146class T0x22<@Q T, @R U> {
147}
148
149/** class type parameter bound */
150class T0x10<T extends @S Object> {
151}
152
153/** method type parameter bound */
154class T0x12<T> {
155    <T extends @A Object> void m0x12() {}
156}
157
158/** class type parameter bound generic/array */
159class T0x11<T extends List<@U T>> {
160}
161
162
163/** method type parameter bound generic/array */
164class T0x13 {
165    static <T extends Comparable<@V T>> T m0x13() {
166        return null;
167    }
168}
169
170/** class extends/implements generic/array */
171class T0x15<T> extends ArrayList<@W T> {
172}
173
174/** type test (instanceof) generic/array */
175class T0x03<T> {
176    void m0x03(T typeObj, Object obj) {
177        boolean ok = obj instanceof String @X [];
178    }
179}
180
181/** object creation (new) generic/array */
182class T0x05<T> {
183    void m0x05() {
184        new ArrayList<@Y T>();
185    }
186}
187
188/** local variable generic/array */
189class T0x09<T> {
190    void g() {
191        List<@Z String> l = null;
192    }
193
194    void a() {
195        String @AA [] as = null;
196    }
197}
198
199/** type argument in constructor call generic/array */
200class T0x19 {
201    <T> T0x19() {}
202
203    void g() {
204       new <List<@AB String>> T0x19();
205    }
206}
207
208/** type argument in method call generic/array */
209class T0x1B<T> {
210    void m0x1B() {
211        Collections.<T @AC []>emptyList();
212    }
213}
214
215/** type argument in constructor call */
216class T0x18<T> {
217    <T> T0x18() {}
218
219    void m() {
220        new <@AD Integer> T0x18();
221    }
222}
223
224/** type argument in method call */
225class T0x1A<T,U> {
226    public static <T, U> T m() { return null; }
227    static void m0x1A() {
228        T0x1A.<@AE Integer, @AF Short>m();
229    }
230}
231
232/** class extends/implements */
233class T0x14 extends @AG Object implements @AH Serializable, @AI Cloneable {
234}
235
236/** exception type in throws */
237class T0x16 {
238    void m0x16() throws @AJ Exception {}
239}
240