1 |
|
2 /* |
|
3 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 * |
|
6 * This code is free software; you can redistribute it and/or modify it |
|
7 * under the terms of the GNU General Public License version 2 only, as |
|
8 * published by the Free Software Foundation. |
|
9 * |
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
|
14 * accompanied this code). |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License version |
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 * |
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 * or visit www.oracle.com if you need additional information or have any |
|
22 * questions. |
|
23 */ |
|
24 |
|
25 /* |
|
26 * @test |
|
27 * @bug 6843077 |
|
28 * @summary random tests for new locations |
|
29 * @author Matt Papi |
|
30 * @compile/fail/ref=BasicTest.out -XDrawDiagnostics BasicTest.java |
|
31 */ |
|
32 |
|
33 import java.util.*; |
|
34 import java.io.*; |
|
35 |
|
36 @interface A {} |
|
37 @interface B {} |
|
38 @interface C {} |
|
39 @interface D {} |
|
40 |
|
41 //308: Test inverted to verify that type annotations can not be parsed yet. |
|
42 |
|
43 /** |
|
44 * Tests basic JSR 308 parser functionality. We don't really care about what |
|
45 * the parse tree looks like, just that these annotations can be parsed. |
|
46 */ |
|
47 class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> { |
|
48 |
|
49 void test() { |
|
50 |
|
51 // Handle annotated class literals/cast types |
|
52 Class<?> c = @A String.class; |
|
53 Object o = (@A Object) "foo"; |
|
54 |
|
55 // Handle annotated "new" expressions (except arrays; see ArrayTest) |
|
56 String s = new @A String("bar"); |
|
57 |
|
58 boolean b = o instanceof @A Object; |
|
59 |
|
60 |
|
61 @A Map<@B List<@C String>, @D String> map = |
|
62 new @A HashMap<@B List<@C String>, @D String>(); |
|
63 |
|
64 Class<? extends @A String> c2 = @A String.class; |
|
65 } |
|
66 |
|
67 // Handle receiver annotations |
|
68 // Handle annotations on a qualified identifier list |
|
69 void test2() @C @D throws @A IllegalArgumentException, @B IOException { |
|
70 |
|
71 } |
|
72 |
|
73 // Handle annotations on a varargs element type |
|
74 void test3(Object @A... objs) { |
|
75 |
|
76 } |
|
77 } |
|