15385
|
1 |
|
|
2 |
/*
|
|
3 |
* Copyright (c) 2008, 2013, 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 8006775
|
|
28 |
* @summary random tests for new locations
|
|
29 |
* @author Matt Papi
|
|
30 |
* @compile BasicTest.java
|
|
31 |
*/
|
|
32 |
|
|
33 |
import java.lang.annotation.*;
|
|
34 |
import java.util.*;
|
|
35 |
import java.io.*;
|
|
36 |
|
|
37 |
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
|
38 |
@interface A {}
|
|
39 |
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
|
40 |
@interface B {}
|
|
41 |
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
|
42 |
@interface C {}
|
|
43 |
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
|
44 |
@interface D {}
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Tests basic JSR 308 parser functionality. We don't really care about what
|
|
48 |
* the parse tree looks like, just that these annotations can be parsed.
|
|
49 |
*/
|
|
50 |
class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
|
|
51 |
|
|
52 |
void test() {
|
|
53 |
|
|
54 |
// Handle annotated cast types
|
|
55 |
Object o = (@A Object) "foo";
|
|
56 |
|
|
57 |
// Handle annotated "new" expressions (except arrays; see ArrayTest)
|
|
58 |
String s = new @A String("bar");
|
|
59 |
|
|
60 |
boolean b = o instanceof @A Object;
|
|
61 |
|
|
62 |
@A Map<@B List<@C String>, @D String> map =
|
|
63 |
new @A HashMap<@B List<@C String>, @D String>();
|
|
64 |
|
|
65 |
Class<? extends @A String> c2 = null;
|
|
66 |
}
|
|
67 |
|
|
68 |
// Handle receiver annotations
|
|
69 |
// Handle annotations on a qualified identifier list
|
|
70 |
void test2(@C @D BasicTest<T> this) throws @A IllegalArgumentException, @B IOException {
|
|
71 |
|
|
72 |
}
|
|
73 |
|
|
74 |
// Handle annotations on a varargs element type
|
|
75 |
void test3(@B Object @A... objs) { }
|
|
76 |
|
|
77 |
void test4(@B Class<@C ?> @A ... clz) { }
|
|
78 |
|
|
79 |
|
|
80 |
// TODO: add more tests... nested classes, etc.
|
|
81 |
}
|