test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java

changeset 1521
71f35e4b93a5
child 1534
bec996065c45
equal deleted inserted replaced
1520:5c956be64b9e 1521:71f35e4b93a5
1 /*
2 * Copyright (c) 2012 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 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
25
26 /*
27 * @test
28 * @summary Test population of reference info for nested types
29 * @compile -g Driver.java ReferenceInfoUtil.java NestedTypes.java
30 * @run main Driver NestedTypes
31 */
32 public class NestedTypes {
33
34 // method parameters
35
36 @TADescriptions({
37 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
38 genericLocation = {}, paramIndex = 0),
39 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
40 genericLocation = {1, 0}, paramIndex = 0)
41 })
42 public String testParam1() {
43 return "void test(@TA Outer.@TB Inner a) { }";
44 }
45
46 @TADescriptions({
47 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
48 genericLocation = {3, 0}, paramIndex = 0),
49 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
50 genericLocation = {3, 0, 1, 0}, paramIndex = 0)
51 })
52 public String testParam1b() {
53 return "void test(List<@TA Outer.@TB Inner> a) { }";
54 }
55
56 // TODO: the tests that use @TA Map.Entry should fail, as
57 // Map cannot be annotated.
58 // We need some tests for the fully qualified name syntax.
59 /*
60 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
61 genericLocation = {}, paramIndex = 0)
62 public String testParam1c() {
63 return "void test(java.util.@TA Map.Entry a) { }";
64 }
65
66 @TADescriptions({
67 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
68 genericLocation = {}, paramIndex = 0),
69 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
70 genericLocation = {1, 0}, paramIndex = 0)
71 })
72 public String testParam1d() {
73 return "void test(java.util.@TA Map.@TB Entry a) { }";
74 }
75
76 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
77 genericLocation = {3, 0}, paramIndex = 0)
78 public String testParam1e() {
79 return "void test(List<java.util.@TA Map.Entry> a) { }";
80 }
81
82 @TADescriptions({
83 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
84 genericLocation = {3, 0}, paramIndex = 0),
85 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
86 genericLocation = {3, 0, 1, 0}, paramIndex = 0)
87 })
88 public String testParam1f() {
89 return "void test(List<java.util.@TA Map. @TB Entry> a) { }";
90 }
91 */
92
93 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
94 genericLocation = {3, 0}, paramIndex = 0)
95 public String testParam1g() {
96 return "void test(List<java.util.Map. @TB Entry> a) { }";
97 }
98
99 @TADescriptions({
100 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
101 genericLocation = {}, paramIndex = 0),
102 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
103 genericLocation = {1, 0}, paramIndex = 0)
104 })
105 public String testParam2() {
106 return "void test(@TA GOuter<String,String>.@TB GInner<String,String> a) { }";
107 }
108
109 @TADescriptions({
110 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
111 genericLocation = {3, 0}, paramIndex = 0),
112 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
113 genericLocation = {3, 0, 1, 0}, paramIndex = 0)
114 })
115 public String testParam2b() {
116 return "void test(List<@TA GOuter<String,String>.@TB GInner<String,String>> a) { }";
117 }
118
119 @TADescriptions({
120 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
121 genericLocation = {0, 0, 0, 0}, paramIndex = 0),
122 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
123 genericLocation = {0, 0, 0, 0, 1, 0}, paramIndex = 0),
124 @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
125 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0}, paramIndex = 0),
126 @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
127 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0),
128 @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
129 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0}, paramIndex = 0),
130 @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
131 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}, paramIndex = 0),
132 @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
133 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}, paramIndex = 0),
134 @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
135 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0),
136 @TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
137 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0),
138 @TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
139 @TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
140 genericLocation = {0, 0}, paramIndex = 0)
141 })
142 public String testParam3() {
143 return "class Outer {\n" +
144 " class GInner<X> {\n" +
145 " class GInner2<Y, Z> {}\n" +
146 "}}\n\n" +
147 "class Test {\n" +
148 " void test(@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] a) { }\n" +
149 "}";
150 }
151
152 @TADescriptions({
153 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
154 genericLocation = {3, 0, 0, 0, 0, 0}, paramIndex = 0),
155 @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
156 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}, paramIndex = 0),
157 @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
158 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0}, paramIndex = 0),
159 @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
160 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0),
161 @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
162 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0}, paramIndex = 0),
163 @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
164 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}, paramIndex = 0),
165 @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
166 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}, paramIndex = 0),
167 @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
168 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0),
169 @TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
170 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0),
171 @TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
172 genericLocation = {3, 0}, paramIndex = 0),
173 @TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
174 genericLocation = {3, 0, 0, 0}, paramIndex = 0)
175 })
176 public String testParam4() {
177 return "class Outer {\n" +
178 " class GInner<X> {\n" +
179 " class GInner2<Y, Z> {}\n" +
180 "}}\n\n" +
181 "class Test {\n" +
182 " void test(List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> a) { }\n" +
183 "}";
184 }
185
186
187 // Local variables
188
189 @TADescriptions({
190 @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
191 genericLocation = {},
192 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
193 @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
194 genericLocation = {1, 0},
195 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
196 })
197 public String testLocal1a() {
198 return "void test() { @TA Outer.@TB Inner a = null; }";
199 }
200
201 @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
202 genericLocation = {},
203 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
204 public String testLocal1b() {
205 return "void test() { @TA Outer.Inner a = null; }";
206 }
207
208 @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
209 genericLocation = {1, 0},
210 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
211 public String testLocal1c() {
212 return "void test() { Outer.@TB Inner a = null; }";
213 }
214
215 @TADescriptions({
216 @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
217 genericLocation = {},
218 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
219 @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
220 genericLocation = {1, 0},
221 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
222 })
223 public String testLocal2() {
224 return "void test() { @TA GOuter<String,String>.@TB GInner<String,String> a = null; }";
225 }
226
227 @TADescriptions({
228 @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
229 genericLocation = {0, 0, 0, 0},
230 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
231 @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
232 genericLocation = {0, 0, 0, 0, 1, 0},
233 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
234 @TADescription(annotation = "TC", type = LOCAL_VARIABLE,
235 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0},
236 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
237 @TADescription(annotation = "TD", type = LOCAL_VARIABLE,
238 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
239 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
240 @TADescription(annotation = "TE", type = LOCAL_VARIABLE,
241 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0},
242 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
243 @TADescription(annotation = "TF", type = LOCAL_VARIABLE,
244 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0},
245 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
246 @TADescription(annotation = "TG", type = LOCAL_VARIABLE,
247 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0},
248 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
249 @TADescription(annotation = "TH", type = LOCAL_VARIABLE,
250 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0},
251 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
252 @TADescription(annotation = "TI", type = LOCAL_VARIABLE,
253 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1},
254 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
255 @TADescription(annotation = "TJ", type = LOCAL_VARIABLE,
256 genericLocation = {},
257 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
258 @TADescription(annotation = "TK", type = LOCAL_VARIABLE,
259 genericLocation = {0, 0},
260 lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1})
261 })
262 public String testLocal3() {
263 return "class Outer {\n" +
264 " class GInner<X> {\n" +
265 " class GInner2<Y, Z> {}\n" +
266 "}}\n\n" +
267 "class Test {\n" +
268 " void test() { @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] a = null; }\n" +
269 "}";
270 }
271
272 @TADescriptions({
273 @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
274 genericLocation = {3, 0, 0, 0, 0, 0},
275 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
276 @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
277 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0},
278 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
279 @TADescription(annotation = "TC", type = LOCAL_VARIABLE,
280 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0},
281 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
282 @TADescription(annotation = "TD", type = LOCAL_VARIABLE,
283 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
284 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
285 @TADescription(annotation = "TE", type = LOCAL_VARIABLE,
286 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0},
287 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
288 @TADescription(annotation = "TF", type = LOCAL_VARIABLE,
289 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0},
290 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
291 @TADescription(annotation = "TG", type = LOCAL_VARIABLE,
292 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0},
293 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
294 @TADescription(annotation = "TH", type = LOCAL_VARIABLE,
295 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0},
296 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
297 @TADescription(annotation = "TI", type = LOCAL_VARIABLE,
298 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1},
299 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
300 @TADescription(annotation = "TJ", type = LOCAL_VARIABLE,
301 genericLocation = {3, 0},
302 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
303 @TADescription(annotation = "TK", type = LOCAL_VARIABLE,
304 genericLocation = {3, 0, 0, 0},
305 lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
306 })
307 public String testLocal4() {
308 return "class Outer {\n" +
309 " class GInner<X> {\n" +
310 " class GInner2<Y, Z> {}\n" +
311 "}}\n\n" +
312 "class Test {\n" +
313 " void test() { List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> a = null; }\n" +
314 "}";
315 }
316
317
318 // fields
319
320 @TADescriptions({
321 @TADescription(annotation = "TA", type = FIELD,
322 genericLocation = {}),
323 @TADescription(annotation = "TB", type = FIELD,
324 genericLocation = {1, 0})
325 })
326 public String testField1a() {
327 return "@TA Outer.@TB Inner a;";
328 }
329
330 @TADescription(annotation = "TA", type = FIELD,
331 genericLocation = {})
332 public String testField1b() {
333 return "@TA Outer.Inner a;";
334 }
335
336 @TADescription(annotation = "TB", type = FIELD,
337 genericLocation = {1, 0})
338 public String testField1c() {
339 return "Outer.@TB Inner a;";
340 }
341
342 @TADescriptions({
343 @TADescription(annotation = "TA", type = FIELD,
344 genericLocation = {}),
345 @TADescription(annotation = "TB", type = FIELD,
346 genericLocation = {1, 0})
347 })
348 public String testField2() {
349 return "@TA GOuter<String,String>.@TB GInner<String,String> a;";
350 }
351
352 @TADescriptions({
353 @TADescription(annotation = "TA", type = FIELD,
354 genericLocation = {0, 0, 0, 0}),
355 @TADescription(annotation = "TB", type = FIELD,
356 genericLocation = {0, 0, 0, 0, 1, 0}),
357 @TADescription(annotation = "TC", type = FIELD,
358 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0}),
359 @TADescription(annotation = "TD", type = FIELD,
360 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
361 @TADescription(annotation = "TE", type = FIELD,
362 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
363 @TADescription(annotation = "TF", type = FIELD,
364 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
365 @TADescription(annotation = "TG", type = FIELD,
366 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}),
367 @TADescription(annotation = "TH", type = FIELD,
368 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
369 @TADescription(annotation = "TI", type = FIELD,
370 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
371 @TADescription(annotation = "TJ", type = FIELD),
372 @TADescription(annotation = "TK", type = FIELD,
373 genericLocation = {0, 0})
374 })
375 public String testField3() {
376 return "class Outer {\n" +
377 " class GInner<X> {\n" +
378 " class GInner2<Y, Z> {}\n" +
379 "}}\n\n" +
380 "class Test {\n" +
381 " @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] a;\n" +
382 "}";
383 }
384
385 @TADescriptions({
386 @TADescription(annotation = "TA", type = FIELD,
387 genericLocation = {3, 0, 0, 0, 0, 0}),
388 @TADescription(annotation = "TB", type = FIELD,
389 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}),
390 @TADescription(annotation = "TC", type = FIELD,
391 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0}),
392 @TADescription(annotation = "TD", type = FIELD,
393 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
394 @TADescription(annotation = "TE", type = FIELD,
395 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
396 @TADescription(annotation = "TF", type = FIELD,
397 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
398 @TADescription(annotation = "TG", type = FIELD,
399 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}),
400 @TADescription(annotation = "TH", type = FIELD,
401 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
402 @TADescription(annotation = "TI", type = FIELD,
403 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
404 @TADescription(annotation = "TJ", type = FIELD,
405 genericLocation = {3, 0}),
406 @TADescription(annotation = "TK", type = FIELD,
407 genericLocation = {3, 0, 0, 0})
408 })
409 public String testField4() {
410 return "class Outer {\n" +
411 " class GInner<X> {\n" +
412 " class GInner2<Y, Z> {}\n" +
413 "}}\n\n" +
414 "class Test {\n" +
415 " List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> a;\n" +
416 "}";
417 }
418
419
420 // return types
421
422 @TADescriptions({
423 @TADescription(annotation = "TA", type = METHOD_RETURN,
424 genericLocation = {}),
425 @TADescription(annotation = "TB", type = METHOD_RETURN,
426 genericLocation = {1, 0})
427 })
428 public String testReturn1() {
429 return "@TA Outer.@TB Inner test() { return null; }";
430 }
431
432 @TADescriptions({
433 @TADescription(annotation = "TA", type = METHOD_RETURN,
434 genericLocation = {}),
435 @TADescription(annotation = "TB", type = METHOD_RETURN,
436 genericLocation = {1, 0})
437 })
438 public String testReturn2() {
439 return "@TA GOuter<String,String>.@TB GInner<String,String> test() { return null; }";
440 }
441
442 @TADescriptions({
443 @TADescription(annotation = "TA", type = METHOD_RETURN,
444 genericLocation = {0, 0, 0, 0}),
445 @TADescription(annotation = "TB", type = METHOD_RETURN,
446 genericLocation = {0, 0, 0, 0, 1, 0}),
447 @TADescription(annotation = "TC", type = METHOD_RETURN,
448 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0}),
449 @TADescription(annotation = "TD", type = METHOD_RETURN,
450 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
451 @TADescription(annotation = "TE", type = METHOD_RETURN,
452 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
453 @TADescription(annotation = "TF", type = METHOD_RETURN,
454 genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
455 @TADescription(annotation = "TG", type = METHOD_RETURN,
456 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}),
457 @TADescription(annotation = "TH", type = METHOD_RETURN,
458 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
459 @TADescription(annotation = "TI", type = METHOD_RETURN,
460 genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
461 @TADescription(annotation = "TJ", type = METHOD_RETURN),
462 @TADescription(annotation = "TK", type = METHOD_RETURN,
463 genericLocation = {0, 0})
464 })
465 public String testReturn3() {
466 return "class Outer {\n" +
467 " class GInner<X> {\n" +
468 " class GInner2<Y, Z> {}\n" +
469 "}}\n\n" +
470 "class Test {\n" +
471 " @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] test() { return null; }\n" +
472 "}";
473 }
474
475 @TADescriptions({
476 @TADescription(annotation = "TA", type = METHOD_RETURN,
477 genericLocation = {3, 0, 0, 0, 0, 0}),
478 @TADescription(annotation = "TB", type = METHOD_RETURN,
479 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}),
480 @TADescription(annotation = "TC", type = METHOD_RETURN,
481 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0}),
482 @TADescription(annotation = "TD", type = METHOD_RETURN,
483 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
484 @TADescription(annotation = "TE", type = METHOD_RETURN,
485 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
486 @TADescription(annotation = "TF", type = METHOD_RETURN,
487 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
488 @TADescription(annotation = "TG", type = METHOD_RETURN,
489 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}),
490 @TADescription(annotation = "TH", type = METHOD_RETURN,
491 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
492 @TADescription(annotation = "TI", type = METHOD_RETURN,
493 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
494 @TADescription(annotation = "TJ", type = METHOD_RETURN,
495 genericLocation = {3, 0}),
496 @TADescription(annotation = "TK", type = METHOD_RETURN,
497 genericLocation = {3, 0, 0, 0})
498 })
499 public String testReturn4() {
500 return "class Outer {\n" +
501 " class GInner<X> {\n" +
502 " class GInner2<Y, Z> {}\n" +
503 "}}\n\n" +
504 "class Test {\n" +
505 " List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> test() { return null; }\n" +
506 "}";
507 }
508
509 @TADescriptions({
510 @TADescription(annotation = "TA", type = METHOD_RETURN,
511 genericLocation = {3, 0}),
512 @TADescription(annotation = "TB", type = METHOD_RETURN,
513 genericLocation = {3, 0, 3, 0}),
514 @TADescription(annotation = "TC", type = METHOD_RETURN,
515 genericLocation = {3, 0, 3, 1}),
516 @TADescription(annotation = "TD", type = METHOD_RETURN,
517 genericLocation = {3, 0, 3, 1, 3, 0}),
518 @TADescription(annotation = "TE", type = METHOD_RETURN,
519 genericLocation = {3, 0, 1, 0}),
520 @TADescription(annotation = "TF", type = METHOD_RETURN,
521 genericLocation = {3, 0, 1, 0, 3, 0}),
522 @TADescription(annotation = "TG", type = METHOD_RETURN,
523 genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
524 @TADescription(annotation = "TH", type = METHOD_RETURN,
525 genericLocation = {3, 0, 1, 0, 3, 0, 3, 0}),
526 @TADescription(annotation = "TI", type = METHOD_RETURN,
527 genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
528 @TADescription(annotation = "TJ", type = METHOD_RETURN,
529 genericLocation = {3, 0, 1, 0, 1, 0}),
530 })
531 public String testReturn5() {
532 return "class GOuter<A, B> {\n" +
533 " class GInner<X> {\n" +
534 " class GInner2<Y, Z> {}\n" +
535 "}}\n\n" +
536 "class Test {\n" +
537 " List<@TA GOuter<@TB String, @TC List<@TD Object>> . @TE GInner<@TF List<@TG Object @TH[] @TI[]>>. @TJ GInner2<String, String>> test() { return null; }\n" +
538 "}";
539 }
540
541
542 // type parameters
543
544 @TADescriptions({
545 @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
546 genericLocation = {}, paramIndex = 0, boundIndex = 0),
547 @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
548 genericLocation = {1, 0}, paramIndex = 0, boundIndex = 0)
549 })
550 public String testTypeparam1() {
551 return "<X extends @TA Outer.@TB Inner> X test() { return null; }";
552 }
553
554 @TADescriptions({
555 @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
556 genericLocation = {}, paramIndex = 0, boundIndex = 0),
557 @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
558 genericLocation = {1, 0}, paramIndex = 0, boundIndex = 0)
559 })
560 public String testTypeparam2() {
561 return "<X extends @TA GOuter<String,String>.@TB GInner<String,String>> X test() { return null; }";
562 }
563
564 @TADescriptions({
565 @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
566 genericLocation = {},
567 paramIndex = 0, boundIndex = 0),
568 @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
569 genericLocation = {1, 0},
570 paramIndex = 0, boundIndex = 0),
571 @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
572 genericLocation = {1, 0, 3, 0},
573 paramIndex = 0, boundIndex = 0),
574 @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
575 genericLocation = {1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
576 paramIndex = 0, boundIndex = 0),
577 @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
578 genericLocation = {1, 0, 3, 0, 3, 0},
579 paramIndex = 0, boundIndex = 0),
580 @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND,
581 genericLocation = {1, 0, 3, 0, 3, 0, 0, 0},
582 paramIndex = 0, boundIndex = 0),
583 @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND,
584 genericLocation = {1, 0, 1, 0},
585 paramIndex = 0, boundIndex = 0),
586 @TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER_BOUND,
587 genericLocation = {1, 0, 1, 0, 3, 0},
588 paramIndex = 0, boundIndex = 0),
589 @TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER_BOUND,
590 genericLocation = {1, 0, 1, 0, 3, 1},
591 paramIndex = 0, boundIndex = 0),
592 })
593 public String testTypeparam3() {
594 return "class Outer {\n" +
595 " class GInner<X> {\n" +
596 " class GInner2<Y, Z> {}\n" +
597 "}}\n\n" +
598 "class Test {\n" +
599 " <X extends @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object>> X test() { return null; }\n" +
600 "}";
601 }
602
603 @TADescriptions({
604 @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
605 genericLocation = {3, 0, 0, 0, 0, 0},
606 paramIndex = 0, boundIndex = 1),
607 @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
608 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0},
609 paramIndex = 0, boundIndex = 1),
610 @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
611 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0},
612 paramIndex = 0, boundIndex = 1),
613 @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
614 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
615 paramIndex = 0, boundIndex = 1),
616 @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
617 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0},
618 paramIndex = 0, boundIndex = 1),
619 @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND,
620 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0},
621 paramIndex = 0, boundIndex = 1),
622 @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND,
623 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0},
624 paramIndex = 0, boundIndex = 1),
625 @TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER_BOUND,
626 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0},
627 paramIndex = 0, boundIndex = 1),
628 @TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER_BOUND,
629 genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1},
630 paramIndex = 0, boundIndex = 1),
631 @TADescription(annotation = "TJ", type = METHOD_TYPE_PARAMETER_BOUND,
632 genericLocation = {3, 0},
633 paramIndex = 0, boundIndex = 1),
634 @TADescription(annotation = "TK", type = METHOD_TYPE_PARAMETER_BOUND,
635 genericLocation = {3, 0, 0, 0},
636 paramIndex = 0, boundIndex = 1)
637 })
638 public String testTypeparam4() {
639 return "class Outer {\n" +
640 " class GInner<X> {\n" +
641 " class GInner2<Y, Z> {}\n" +
642 "}}\n\n" +
643 "class Test {\n" +
644 " <X extends List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]>> X test() { return null; }\n" +
645 "}";
646 }
647
648 @TADescriptions({
649 @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
650 genericLocation = {3, 0}, paramIndex = 0, boundIndex = 1),
651 @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
652 genericLocation = {3, 0, 3, 0}, paramIndex = 0, boundIndex = 1),
653 @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
654 genericLocation = {3, 0, 3, 1}, paramIndex = 0, boundIndex = 1),
655 @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
656 genericLocation = {3, 0, 3, 1, 3, 0}, paramIndex = 0, boundIndex = 1),
657 @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
658 genericLocation = {3, 0, 1, 0}, paramIndex = 0, boundIndex = 1),
659 @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND,
660 genericLocation = {3, 0, 1, 0, 3, 0}, paramIndex = 0, boundIndex = 1),
661 @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND,
662 genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0, boundIndex = 1),
663 @TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER_BOUND,
664 genericLocation = {3, 0, 1, 0, 3, 0, 3, 0}, paramIndex = 0, boundIndex = 1),
665 @TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER_BOUND,
666 genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0}, paramIndex = 0, boundIndex = 1),
667 @TADescription(annotation = "TJ", type = METHOD_TYPE_PARAMETER_BOUND,
668 genericLocation = {3, 0, 1, 0, 1, 0}, paramIndex = 0, boundIndex = 1),
669 })
670 public String testTypeparam5() {
671 return "class GOuter<A, B> {\n" +
672 " class GInner<X> {\n" +
673 " class GInner2<Y, Z> {}\n" +
674 "}}\n\n" +
675 "class Test {\n" +
676 " <X extends List<@TA GOuter<@TB String, @TC List<@TD Object>> . @TE GInner<@TF List<@TG Object @TH[] @TI[]>>. @TJ GInner2<String, String>>> X test() { return null; }\n" +
677 "}";
678 }
679
680 @TADescription(annotation = "TA", type = FIELD,
681 genericLocation = {3, 0, 1, 0})
682 public String testUses1a() {
683 return "class Test { class Inner {} List<@TA Inner> f; }";
684 }
685
686 @TADescription(annotation = "TA", type = FIELD,
687 genericLocation = {3, 0})
688 public String testUses1b() {
689 return "class Test { class Inner {} List<@TA Test.Inner> f; }";
690 }
691
692 @TADescription(annotation = "TA", type = FIELD,
693 genericLocation = {3, 0, 1, 0, 1, 0})
694 @TestClass("Test$Inner")
695 public String testUses2a() {
696 return "class Test { class Inner { class Inner2{} List<@TA Inner2> f; }}";
697 }
698
699 @TADescription(annotation = "TA", type = FIELD,
700 genericLocation = {3, 0, 1, 0})
701 @TestClass("Test$Inner")
702 public String testUses2b() {
703 return "class Test { class Inner { class Inner2{} List<@TA Inner.Inner2> f; }}";
704 }
705
706 @TADescription(annotation = "TA", type = FIELD,
707 genericLocation = {3, 0, 1, 0, 1, 0})
708 @TestClass("Test$Inner")
709 public String testUses2c() {
710 return "class Test { class Inner { class Inner2{} List<Inner.@TA Inner2> f; }}";
711 }
712
713 @TADescription(annotation = "TA", type = FIELD,
714 genericLocation = {3, 0})
715 @TestClass("Test$Inner")
716 public String testUses2d() {
717 return "class Test{ class Inner { class Inner2{} List<@TA Test.Inner.Inner2> f; }}";
718 }
719
720 @TADescription(annotation = "TA", type = FIELD,
721 genericLocation = {3, 0, 1, 0})
722 @TestClass("Test$Inner")
723 public String testUses2e() {
724 return "class Test { class Inner { class Inner2{} List<Test.@TA Inner.Inner2> f; }}";
725 }
726
727 @TADescription(annotation = "TA", type = FIELD,
728 genericLocation = {3, 0, 1, 0, 1, 0})
729 @TestClass("Test$Inner")
730 public String testUses2f() {
731 return "class Test { class Inner { class Inner2{} List<Test.Inner.@TA Inner2> f; }}";
732 }
733
734 @TADescription(annotation = "TA", type = FIELD,
735 genericLocation = {3, 0, 1, 0, 1, 0})
736 @TestClass("Test$Inner")
737 public String testUses3a() {
738 return "class Test { class Inner<A, B> { class Inner2<C, D>{}\n" +
739 " List<Test.Inner.@TA Inner2> f; }}";
740 }
741
742 @TADescription(annotation = "TA", type = FIELD,
743 genericLocation = {3, 0, 1, 0})
744 @TestClass("Test$Inner")
745 public String testUses3b() {
746 return "class Test { class Inner<A, B> { class Inner2<C, D>{}\n" +
747 " List<Test.@TA Inner.Inner2> f; }}";
748 }
749
750 @TADescriptions({
751 @TADescription(annotation = "TA", type = FIELD,
752 genericLocation = {}),
753 @TADescription(annotation = "TB", type = FIELD,
754 genericLocation = {3, 0})
755 })
756 public String testUses4() {
757 return "class Test { static class TInner {}\n" +
758 " @TA TInner f; \n" +
759 " List<@TB TInner> g; }";
760 }
761
762 @TADescription(annotation = "TA", type = FIELD,
763 genericLocation = {3, 0, 1, 0, 3, 1})
764 @TestClass("Test$Inner")
765 public String testUses3c() {
766 return "class Test { class Inner<A, B> { class Inner2<C, D>{}\n" +
767 " List<Test.Inner<String, @TA Object>.Inner2<Test, Test>> f; }}";
768 }
769
770 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex=0)
771 public String testFullyQualified1() {
772 return "void testme(java.security.@TA ProtectionDomain protectionDomain) {}";
773 }
774
775 @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex=0,
776 genericLocation = {3, 0})
777 public String testFullyQualified2() {
778 return "void testme(List<java.security.@TA ProtectionDomain> protectionDomain) {}";
779 }
780
781 @TADescriptions({
782 @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
783 genericLocation = {},
784 lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
785 lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
786 lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
787 @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
788 genericLocation = {1, 0},
789 lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
790 lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
791 lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
792 @TADescription(annotation = "TC", type = LOCAL_VARIABLE,
793 // Only classes count, not methods.
794 genericLocation = {1, 0, 1, 0},
795 lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
796 lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
797 lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
798 })
799 @TestClass("Outer$Inner")
800 public String testMethodNesting1() {
801 return "class Outer {\n" +
802 " class Inner {\n" +
803 " void foo() {\n" +
804 " class MInner {}\n" +
805 " @TA Outer . @TB Inner l1 = null;\n" +
806 " @TC MInner l2 = null;\n" +
807 " }\n" +
808 "}}\n";
809 }
810
811 @TADescriptions({
812 @TADescription(annotation = "TA", type = NEW,
813 genericLocation = {},
814 offset = 0),
815 @TADescription(annotation = "TB", type = NEW,
816 genericLocation = {1, 0},
817 offset = 0),
818 @TADescription(annotation = "TC", type = NEW,
819 // Only classes count, not methods.
820 genericLocation = {1, 0, 1, 0},
821 offset = 12),
822 })
823 @TestClass("Outer$Inner")
824 public String testMethodNesting2() {
825 return "class Outer {\n" +
826 " class Inner {\n" +
827 " void foo() {\n" +
828 " class MInner {}\n" +
829 " Object o1 = new @TA Outer . @TB Inner();" +
830 " Object o2 = new @TC MInner();\n" +
831 " }\n" +
832 "}}\n";
833 }
834 }

mercurial