Skip to content

Commit 83b3bbb

Browse files
author
duke
committed
Backport d562d3c7a9e1e857c095ef908b0957b033972949
1 parent 9e811f1 commit 83b3bbb

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,18 @@ public Void scan(Element elem, Void ignore) {
163163
*/
164164
class TestTypeScanner extends TypeScanner<Void, Void> {
165165
Element elem;
166-
NavigableMap<Integer, AnnotationMirror> toBeFound;
166+
NavigableMap<Integer, List<AnnotationMirror>> toBeFound;
167167
int count = 0;
168168
Set<TypeMirror> seen = new HashSet<>();
169169

170170
TestTypeScanner(Element elem, List<AnnotationMirror> tests, Types types) {
171171
super(types);
172172
this.elem = elem;
173173

174-
NavigableMap<Integer, AnnotationMirror> testByPos = new TreeMap<>();
174+
NavigableMap<Integer, List<AnnotationMirror>> testByPos = new TreeMap<>();
175175
for (AnnotationMirror test : tests) {
176176
for (int pos : getPosn(test)) {
177-
testByPos.put(pos, test);
177+
testByPos.computeIfAbsent(pos, ArrayList::new).add(test);
178178
}
179179
}
180180
this.toBeFound = testByPos;
@@ -196,17 +196,18 @@ Void scan(TypeMirror t, Void ignore) {
196196
out.println("scan " + count + ": " + t);
197197
if (toBeFound.size() > 0) {
198198
if (toBeFound.firstKey().equals(count)) {
199-
AnnotationMirror test = toBeFound.pollFirstEntry().getValue();
200-
String annoType = getAnnoType(test);
201-
AnnotationMirror anno = getAnnotation(t, annoType);
202-
if (anno == null) {
203-
error(elem, "annotation not found on " + count + ": " + t);
204-
} else {
205-
String v = getValue(anno, "value").toString();
206-
if (v.equals(getExpect(test))) {
207-
out.println("found " + anno + " as expected");
199+
for (AnnotationMirror test : toBeFound.pollFirstEntry().getValue()) {
200+
String annoType = getAnnoType(test);
201+
AnnotationMirror anno = getAnnotation(t, annoType);
202+
if (anno == null) {
203+
error(elem, "annotation not found on " + count + ": " + t);
208204
} else {
209-
error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test));
205+
String v = getValue(anno, "value").toString();
206+
if (v.equals(getExpect(test))) {
207+
out.println("found " + anno + " as expected");
208+
} else {
209+
error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test));
210+
}
210211
}
211212
}
212213
} else if (count > toBeFound.firstKey()) {

0 commit comments

Comments
 (0)