author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 29842 | 826ac2519523 |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
17578 | 1 |
/* |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
17578 | 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 |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
26 |
* @bug 8013852 8031744 |
17578 | 27 |
* @summary Annotations on types |
28 |
* @library /tools/javac/lib |
|
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29842
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29842
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.code |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29842
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.processing |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29842
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.tree |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29842
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.javac.util |
17578 | 34 |
* @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests |
35 |
* @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java |
|
36 |
*/ |
|
37 |
||
38 |
import java.io.PrintWriter; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
39 |
import java.io.Serializable; |
17578 | 40 |
import java.lang.annotation.Annotation; |
41 |
import java.lang.annotation.ElementType; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
42 |
import java.lang.annotation.Repeatable; |
17578 | 43 |
import java.lang.annotation.Target; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
44 |
import java.util.ArrayList; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
45 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
46 |
import java.util.HashSet; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
47 |
import java.util.List; |
17578 | 48 |
import java.util.Map; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
49 |
import java.util.NavigableMap; |
17578 | 50 |
import java.util.Set; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
51 |
import java.util.TreeMap; |
17578 | 52 |
|
53 |
import javax.annotation.processing.ProcessingEnvironment; |
|
54 |
import javax.annotation.processing.RoundEnvironment; |
|
55 |
import javax.lang.model.AnnotatedConstruct; |
|
56 |
import javax.lang.model.element.AnnotationMirror; |
|
57 |
import javax.lang.model.element.AnnotationValue; |
|
58 |
import javax.lang.model.element.Element; |
|
59 |
import javax.lang.model.element.ExecutableElement; |
|
60 |
import javax.lang.model.element.TypeElement; |
|
61 |
import javax.lang.model.type.ArrayType; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
62 |
import javax.lang.model.type.DeclaredType; |
17578 | 63 |
import javax.lang.model.type.ExecutableType; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
64 |
import javax.lang.model.type.IntersectionType; |
17578 | 65 |
import javax.lang.model.type.TypeMirror; |
66 |
import javax.lang.model.type.TypeVariable; |
|
67 |
import javax.lang.model.type.WildcardType; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
68 |
import javax.lang.model.util.Types; |
17578 | 69 |
import javax.tools.Diagnostic.Kind; |
70 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
71 |
import com.sun.tools.javac.code.Attribute; |
17578 | 72 |
import com.sun.tools.javac.code.Symbol; |
73 |
import com.sun.tools.javac.processing.JavacProcessingEnvironment; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
74 |
import com.sun.tools.javac.util.Name; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
75 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
76 |
import static com.sun.tools.javac.code.Attribute.Array; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
77 |
import static com.sun.tools.javac.code.Attribute.Constant; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
78 |
import static com.sun.tools.javac.code.Attribute.Compound; |
17578 | 79 |
|
80 |
/** |
|
81 |
* The test scans this file looking for test cases annotated with @Test. |
|
82 |
*/ |
|
83 |
public class BasicAnnoTests extends JavacTestingAbstractProcessor { |
|
84 |
DPrinter dprinter; |
|
85 |
PrintWriter out; |
|
86 |
boolean verbose = true; |
|
87 |
||
88 |
@Override |
|
89 |
public void init(ProcessingEnvironment pEnv) { |
|
90 |
super.init(pEnv); |
|
91 |
dprinter = new DPrinter(((JavacProcessingEnvironment) pEnv).getContext()); |
|
92 |
out = dprinter.out; |
|
93 |
} |
|
94 |
||
95 |
@Override |
|
96 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
|
97 |
TestElementScanner s = new TestElementScanner(); |
|
98 |
for (Element e: roundEnv.getRootElements()) { |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
99 |
s.scan(e, null); |
17578 | 100 |
} |
101 |
return true; |
|
102 |
} |
|
103 |
||
104 |
void error(Element e, String msg) { |
|
105 |
messager.printMessage(Kind.ERROR, msg, e); |
|
106 |
errors++; |
|
107 |
} |
|
108 |
||
109 |
int errors; |
|
110 |
||
111 |
/** |
|
112 |
* Scan an element looking for declarations annotated with @Test. |
|
113 |
* Run a TestTypeScanner on the annotations that are found. |
|
114 |
*/ |
|
115 |
class TestElementScanner extends ElementScanner<Void,Void> { |
|
116 |
public Void scan(Element elem, Void ignore) { |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
117 |
List<AnnotationMirror> tests = new ArrayList<>(); |
17578 | 118 |
AnnotationMirror test = getAnnotation(elem, Test.class.getName().replace('$', '.')); |
119 |
if (test != null) { |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
120 |
tests.add(test); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
121 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
122 |
tests.addAll(getAnnotations(elem, Tests.class.getName().replace('$', '.'))); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
123 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
124 |
if (tests.size() > 0) { |
17578 | 125 |
out.println("Test: " + elem + " " + test); |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
126 |
TestTypeScanner s = new TestTypeScanner(elem, tests, types); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
127 |
s.test(elem.asType()); |
17578 | 128 |
out.println(); |
129 |
} |
|
130 |
return super.scan(elem, ignore); |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
/** |
|
135 |
* Scan the type of an element, looking for an annotation |
|
136 |
* to match the expected annotation specified in the @Test annotation. |
|
137 |
*/ |
|
138 |
class TestTypeScanner extends TypeScanner<Void, Void> { |
|
139 |
Element elem; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
140 |
NavigableMap<Integer, AnnotationMirror> toBeFound; |
17578 | 141 |
int count = 0; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
142 |
Set<TypeMirror> seen = new HashSet<>(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
143 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
144 |
TestTypeScanner(Element elem, List<AnnotationMirror> tests, Types types) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
145 |
super(types); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
146 |
this.elem = elem; |
17578 | 147 |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
148 |
NavigableMap<Integer, AnnotationMirror> testByPos = new TreeMap<>(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
149 |
for (AnnotationMirror test : tests) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
150 |
for (int pos : getPosn(test)) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
151 |
testByPos.put(pos, test); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
152 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
153 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
154 |
this.toBeFound = testByPos; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
155 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
156 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
157 |
public void test(TypeMirror t) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
158 |
scan(t, null); |
17578 | 159 |
} |
160 |
||
161 |
@Override |
|
162 |
Void scan(TypeMirror t, Void ignore) { |
|
163 |
if (t == null) |
|
164 |
return DEFAULT_VALUE; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
165 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
166 |
if (!seen.contains(t)) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
167 |
try { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
168 |
seen.add(t); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
169 |
if (verbose) |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
170 |
out.println("scan " + count + ": " + t); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
171 |
if (toBeFound.size() > 0) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
172 |
if (toBeFound.firstKey().equals(count)) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
173 |
AnnotationMirror test = toBeFound.pollFirstEntry().getValue(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
174 |
String annoType = getAnnoType(test); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
175 |
AnnotationMirror anno = getAnnotation(t, annoType); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
176 |
if (anno == null) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
177 |
error(elem, "annotation not found on " + count + ": " + t); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
178 |
} else { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
179 |
String v = getValue(anno, "value").toString(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
180 |
if (v.equals(getExpect(test))) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
181 |
out.println("found " + anno + " as expected"); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
182 |
} else { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
183 |
error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test)); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
184 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
185 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
186 |
} else if (count > toBeFound.firstKey()) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
187 |
rescue(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
188 |
} else { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
189 |
List<? extends AnnotationMirror> annos = t.getAnnotationMirrors(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
190 |
if (annos.size() > 0) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
191 |
for (AnnotationMirror a : annos) |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
192 |
error(elem, "annotation " + a + " found on " + count + ": " + t); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
193 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
194 |
} |
17578 | 195 |
} else { |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
196 |
List<? extends AnnotationMirror> annos = t.getAnnotationMirrors(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
197 |
if (annos.size() > 0) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
198 |
for (AnnotationMirror a : annos) |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
199 |
error(elem, "annotation " + a + " found on " + count + ": " + t); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
200 |
} |
17578 | 201 |
} |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
202 |
count++; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
203 |
return super.scan(t, ignore); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
204 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
205 |
} finally { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
206 |
seen.remove(t); |
17578 | 207 |
} |
208 |
} |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
209 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
210 |
return DEFAULT_VALUE; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
211 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
212 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
213 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
214 |
private void rescue() { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
215 |
while (toBeFound.size() > 0 && toBeFound.firstKey() >= count) |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
216 |
toBeFound.pollFirstEntry(); |
17578 | 217 |
} |
218 |
} |
|
219 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
220 |
/** Get the position value from an element annotated with a @Test annotation mirror. */ |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
221 |
static int[] getPosn(Element elem) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
222 |
return elem.getAnnotation(Test.class).posn(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
223 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
224 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
225 |
/** Get the position value from a @Test annotation mirror. */ |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
226 |
static Integer[] getPosn(AnnotationMirror test) { |
17578 | 227 |
AnnotationValue v = getValue(test, "posn"); |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
228 |
Object value = v.getValue(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
229 |
Integer i = 0; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
230 |
if (value instanceof Constant) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
231 |
i = (Integer)((Constant)value).getValue(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
232 |
Integer[] res = new Integer[1]; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
233 |
res[0] = i; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
234 |
return res; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
235 |
} else if (value instanceof List) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
236 |
List<Constant> l = (List<Constant>)value; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
237 |
Integer[] res = new Integer[l.size()]; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
238 |
for (int c = 0; c < l.size(); c++) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
239 |
res[c] = (Integer)l.get(c).getValue(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
240 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
241 |
return res; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
242 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
243 |
return null; |
17578 | 244 |
} |
245 |
||
246 |
/** Get the expect value from an @Test annotation mirror. */ |
|
247 |
static String getExpect(AnnotationMirror test) { |
|
248 |
AnnotationValue v = getValue(test, "expect"); |
|
249 |
return (String) v.getValue(); |
|
250 |
} |
|
251 |
||
252 |
/** Get the annoType value from an @Test annotation mirror. */ |
|
253 |
static String getAnnoType(AnnotationMirror test) { |
|
254 |
AnnotationValue v = getValue(test, "annoType"); |
|
255 |
TypeMirror m = (TypeMirror) v.getValue(); |
|
256 |
return m.toString(); |
|
257 |
} |
|
258 |
||
259 |
/** |
|
260 |
* Get a specific annotation mirror from an annotated construct. |
|
261 |
*/ |
|
262 |
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) { |
|
263 |
for (AnnotationMirror m: e.getAnnotationMirrors()) { |
|
264 |
TypeElement te = (TypeElement) m.getAnnotationType().asElement(); |
|
265 |
if (te.getQualifiedName().contentEquals(name)) { |
|
266 |
return m; |
|
267 |
} |
|
268 |
} |
|
269 |
return null; |
|
270 |
} |
|
271 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
272 |
static List<AnnotationMirror> getAnnotations(Element e, String name) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
273 |
Name valueName = ((Symbol)e).getSimpleName().table.names.value; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
274 |
List<AnnotationMirror> res = new ArrayList<>(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
275 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
276 |
for (AnnotationMirror m : e.getAnnotationMirrors()) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
277 |
TypeElement te = (TypeElement) m.getAnnotationType().asElement(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
278 |
if (te.getQualifiedName().contentEquals(name)) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
279 |
Compound theAnno = (Compound)m; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
280 |
Array valueArray = (Array)theAnno.member(valueName); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
281 |
for (Attribute a : valueArray.getValue()) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
282 |
AnnotationMirror theMirror = (AnnotationMirror) a; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
283 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
284 |
res.add(theMirror); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
285 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
286 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
287 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
288 |
return res; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
289 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
290 |
|
17578 | 291 |
/** |
292 |
* Get a specific value from an annotation mirror. |
|
293 |
*/ |
|
294 |
static AnnotationValue getValue(AnnotationMirror anno, String name) { |
|
295 |
Map<? extends ExecutableElement, ? extends AnnotationValue> map = anno.getElementValues(); |
|
296 |
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> e: map.entrySet()) { |
|
297 |
if (e.getKey().getSimpleName().contentEquals(name)) { |
|
298 |
return e.getValue(); |
|
299 |
} |
|
300 |
} |
|
301 |
return null; |
|
302 |
} |
|
303 |
||
304 |
/** |
|
305 |
* The Language Model API does not provide a type scanner, so provide |
|
306 |
* one sufficient for our needs. |
|
307 |
*/ |
|
308 |
static class TypeScanner<R, P> extends SimpleTypeVisitor<R, P> { |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
309 |
private Types types; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
310 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
311 |
public TypeScanner(Types types) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
312 |
super(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
313 |
this.types = types; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
314 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
315 |
|
17578 | 316 |
@Override |
317 |
public R visitArray(ArrayType t, P p) { |
|
318 |
scan(t.getComponentType(), p); |
|
319 |
return super.visitArray(t, p); |
|
320 |
} |
|
321 |
||
322 |
@Override |
|
323 |
public R visitExecutable(ExecutableType t, P p) { |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
324 |
//out.println(" type parameters: " + t.getTypeVariables()); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
325 |
scan(t.getTypeVariables(), p); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
326 |
//out.println(" return: " + t.getReturnType()); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
327 |
scan(t.getReturnType(), p); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
328 |
//out.println(" receiver: " + t.getReceiverTypes()); |
17578 | 329 |
scan(t.getReceiverType()); |
330 |
//out.println(" params: " + t.getParameterTypes()); |
|
331 |
scan(t.getParameterTypes(), p); |
|
332 |
//out.println(" throws: " + t.getThrownTypes()); |
|
333 |
scan(t.getThrownTypes(), p); |
|
334 |
return super.visitExecutable(t, p); |
|
335 |
} |
|
336 |
||
337 |
@Override |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
338 |
public R visitDeclared(DeclaredType t, P p) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
339 |
scan(t.getTypeArguments(), p); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
340 |
// don't scan enclosing |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
341 |
scan(types.directSupertypes(t), p); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
342 |
return super.visitDeclared(t, p); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
343 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
344 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
345 |
@Override |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
346 |
public R visitIntersection(IntersectionType t, P p) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
347 |
scan(t.getBounds(), p); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
348 |
return super.visitIntersection(t, p); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
349 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
350 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
351 |
@Override |
17578 | 352 |
public R visitTypeVariable(TypeVariable t, P p) { |
353 |
scan(t.getLowerBound(), p); |
|
354 |
scan(t.getUpperBound(), p); |
|
355 |
return super.visitTypeVariable(t, p); |
|
356 |
} |
|
357 |
||
358 |
@Override |
|
359 |
public R visitWildcard(WildcardType t, P p) { |
|
360 |
scan(t.getExtendsBound(), p); |
|
361 |
scan(t.getSuperBound(), p); |
|
362 |
return super.visitWildcard(t, p); |
|
363 |
} |
|
364 |
||
365 |
R scan(TypeMirror t) { |
|
366 |
return scan(t, null); |
|
367 |
} |
|
368 |
||
369 |
R scan(TypeMirror t, P p) { |
|
370 |
return (t == null) ? DEFAULT_VALUE : t.accept(this, p); |
|
371 |
} |
|
372 |
||
373 |
R scan(Iterable<? extends TypeMirror> iter, P p) { |
|
374 |
if (iter == null) |
|
375 |
return DEFAULT_VALUE; |
|
376 |
R result = DEFAULT_VALUE; |
|
377 |
for (TypeMirror t: iter) |
|
378 |
result = scan(t, p); |
|
379 |
return result; |
|
380 |
} |
|
381 |
} |
|
382 |
||
383 |
/** Annotation to identify test cases. */ |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
384 |
@Repeatable(Tests.class) |
17578 | 385 |
@interface Test { |
386 |
/** Where to look for the annotation, expressed as a scan index. */ |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
387 |
int[] posn(); |
17578 | 388 |
/** The annotation to look for. */ |
389 |
Class<? extends Annotation> annoType(); |
|
390 |
/** The string representation of the annotation's value. */ |
|
391 |
String expect(); |
|
392 |
} |
|
393 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
394 |
@interface Tests { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
395 |
Test[] value(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
396 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
397 |
|
17578 | 398 |
/** Type annotation to use in test cases. */ |
399 |
@Target(ElementType.TYPE_USE) |
|
400 |
public @interface TA { |
|
401 |
int value(); |
|
402 |
} |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
403 |
@Target(ElementType.TYPE_USE) |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
404 |
public @interface TB { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
405 |
int value(); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
406 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
407 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
408 |
// Test cases |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
409 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
410 |
// TODO: add more cases for arrays |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
411 |
// all annotated |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
412 |
// all but one annotated |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
413 |
// vary position of one not annotated |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
414 |
// only one annotated |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
415 |
// vary position of one annotated |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
416 |
// the three above with the corner case of the ambiguos decl + type anno added |
17578 | 417 |
|
418 |
@Test(posn=0, annoType=TA.class, expect="1") |
|
419 |
public @TA(1) int f1; |
|
420 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
421 |
@Test(posn=0, annoType=TA.class, expect="11") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
422 |
@TA(11) public int f11; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
423 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
424 |
@Test(posn=1, annoType=TA.class, expect="111") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
425 |
@TA(111) public int [] f111; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
426 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
427 |
@Test(posn=1, annoType=TA.class, expect="1120") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
428 |
@Test(posn=0, annoType=TB.class, expect="1121") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
429 |
@TA(1120) public int @TB(1121) [] f112; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
430 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
431 |
@Test(posn=0, annoType=TB.class, expect="11211") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
432 |
@Test(posn=1, annoType=TA.class, expect="11200") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
433 |
public @TA(11200) int @TB(11211) [] f112b; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
434 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
435 |
@Test(posn=1, annoType=TB.class, expect="1131") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
436 |
@Test(posn=2, annoType=TA.class, expect="1130") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
437 |
@TA(1130) public int [] @TB(1131) [] f113; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
438 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
439 |
@Test(posn=5, annoType=TA.class, expect="12") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
440 |
public @TA(12) int [] [] [] [] [] f12; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
441 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
442 |
@Test(posn=6, annoType=TA.class, expect="13") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
443 |
public @TA(13) int [] [] [] [] [] [] f13; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
444 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
445 |
@Test(posn=7, annoType=TA.class, expect="14") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
446 |
@TA(14) public int [] [] [] [] [] [] [] f14; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
447 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
448 |
@Test(posn=6, annoType=TA.class, expect="150") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
449 |
@Test(posn=7, annoType=TB.class, expect="151") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
450 |
@TB(151) public int [] [] [] [] [] [] @TA(150) [] f15; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
451 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
452 |
@Test(posn=0, annoType=TB.class, expect="1511") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
453 |
@Test(posn=3, annoType=TA.class, expect="1512") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
454 |
@Test(posn=6, annoType=TA.class, expect="150") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
455 |
@Test(posn=7, annoType=TB.class, expect="151") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
456 |
@TB(151) public int @TB(1511) [] [] [] @TA(1512) [] [] [] @TA(150) [] f15b; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
457 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
458 |
@Test(posn=0, annoType=TB.class, expect="1521") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
459 |
@Test(posn=3, annoType=TA.class, expect="1522") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
460 |
@Test(posn=6, annoType=TA.class, expect="152") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
461 |
public int @TB(1521) [] [] [] @TA(1522) [] [] [] @TA(152) [] f15c; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
462 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
463 |
@Test(posn=5, annoType=TA.class, expect="160") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
464 |
@Test(posn=6, annoType=TB.class, expect="161") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
465 |
public int [] [] [] [] [] @TA(160) [] @TB(161) [] f16; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
466 |
|
17578 | 467 |
@Test(posn=0, annoType=TA.class, expect="2") |
468 |
public int @TA(2) [] f2; |
|
469 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
470 |
@Test(posn=0, annoType=TB.class, expect="33") |
17578 | 471 |
@Test(posn=1, annoType=TA.class, expect="3") |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
472 |
public @TA(3) int @TB(33) [] f3; |
17578 | 473 |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
474 |
@Test(posn=2, annoType=TA.class, expect="4") |
17578 | 475 |
public int m1(@TA(4) float a) throws Exception { return 0; } |
476 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
477 |
@Test(posn=1, annoType=TA.class, expect="5") |
17578 | 478 |
public @TA(5) int m2(float a) throws Exception { return 0; } |
479 |
||
480 |
@Test(posn=3, annoType=TA.class, expect="6") |
|
481 |
public int m3(float a) throws @TA(6) Exception { return 0; } |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
482 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
483 |
// Also tests that a decl anno on a typevar doesn't show up on the Type |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
484 |
@Test(posn=7, annoType=TA.class, expect="8") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
485 |
public <@TA(7) M> M m4(@TA(8) float a) throws Exception { return null; } |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
486 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
487 |
// Also tests that a decl anno on a typevar doesn't show up on the Type |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
488 |
@Test(posn=4, annoType=TA.class, expect="10") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
489 |
public class Inner1<@TA(9) S> extends @TA(10) Object implements Cloneable {} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
490 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
491 |
// Also tests that a decl anno on a typevar doesn't show up on the Type |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
492 |
@Test(posn=5, annoType=TA.class, expect="12") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
493 |
public class Inner2<@TA(11) S> extends Object implements @TA(12) Cloneable {} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
494 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
495 |
@Test(posn={3,6}, annoType=TA.class, expect="13") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
496 |
public <M extends @TA(13) Object> M m5(float a) { return null; } |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
497 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
498 |
@Test(posn=3, annoType=TA.class, expect="14") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
499 |
public class Inner3<QQQ extends @TA(14) Map> {} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
500 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
501 |
@Test(posn=4, annoType=TA.class, expect="15") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
502 |
public class Inner4<T extends @TA(15) Object & Cloneable & Serializable> {} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
503 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
504 |
@Test(posn=5, annoType=TA.class, expect="16") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
505 |
public class Inner5<T extends Object & @TA(16) Cloneable & Serializable> {} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
506 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
507 |
@Test(posn=7, annoType=TA.class, expect="17") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
508 |
public class Inner6<T extends Object & Cloneable & @TA(17) Serializable> {} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
509 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
510 |
// Test annotated bounds |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
511 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
512 |
@Test(posn=1, annoType=TA.class, expect="18") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
513 |
public Set<@TA(18) ? extends Object> f4; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
514 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
515 |
@Test(posn=2, annoType=TA.class, expect="19") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
516 |
public Set<? extends @TA(19) Object> f5; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
517 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
518 |
@Test(posn=3, annoType=TA.class, expect="20") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
519 |
public Set<? extends Set<@TA(20) ? extends Object>> f6; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
520 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
521 |
@Test(posn=4, annoType=TA.class, expect="21") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
522 |
public Set<? extends Set<? extends @TA(21) Object>> f7; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
523 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
524 |
@Test(posn=1, annoType=TA.class, expect="22") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
525 |
public Set<@TA(22) ?> f8; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
526 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
527 |
@Test(posn=1, annoType=TA.class, expect="23") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
528 |
public Set<@TA(23) ? super Object> f9; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
529 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
530 |
// Test type use annotations on uses of type variables |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
531 |
@Test(posn=5, annoType = TA.class, expect = "25") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
532 |
@Test(posn=5, annoType = TB.class, expect = "26") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
533 |
<T> void m6(@TA(25) @TB(26) T t) { } |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
534 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
535 |
class Inner7<T> { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
536 |
@Test(posn=0, annoType = TA.class, expect = "30") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
537 |
@Test(posn=0, annoType = TB.class, expect = "31") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
538 |
@TA(30) @TB(31) T f; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
539 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
540 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
541 |
// Test type use annotations on uses of type variables |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
542 |
@Test(posn=5, annoType = TB.class, expect = "41") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
543 |
<@TA(40) T> void m7(@TB(41) T t) { } |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
544 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
545 |
class Inner8<@TA(50) T> { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
546 |
@Test(posn=0, annoType = TB.class, expect = "51") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
547 |
@TB(51) T f; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
548 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
549 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
550 |
// Test type use annotations on uses of Class types |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
551 |
@Test(posn=5, annoType = TA.class, expect = "60") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
552 |
@Test(posn=5, annoType = TB.class, expect = "61") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
553 |
<T> void m60(@TA(60) @TB(61) String t) { } |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
554 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
555 |
class Inner70<T> { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
556 |
@Test(posn=0, annoType = TA.class, expect = "70") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
557 |
@Test(posn=0, annoType = TB.class, expect = "71") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
558 |
@TA(70) @TB(71) String f; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
559 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
560 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
561 |
// Test type use annotations on uses of type variables |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
562 |
@Test(posn=5, annoType = TB.class, expect = "81") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
563 |
<@TA(80) T> void m80(@TB(81) String t) { } |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
564 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
565 |
class Inner90<@TA(90) T> { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
566 |
@Test(posn=0, annoType = TB.class, expect = "91") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
567 |
@TB(91) String f; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
568 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
569 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
570 |
// Recursive bound |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
571 |
@Test(posn=4, annoType = TB.class, expect = "100") |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
572 |
class Inner100<T extends Inner100<@TB(100) T>> { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
26532
diff
changeset
|
573 |
} |
17578 | 574 |
} |