8206325: AssertionError in TypeSymbol.getAnnotationTypeMetadata
Reviewed-by: mcimadamore
This commit is contained in:
parent
1285c3cd30
commit
10d83827bc
@ -169,9 +169,12 @@ public class TypeAnnotations {
|
||||
|
||||
/**
|
||||
* Determine whether an annotation is a declaration annotation,
|
||||
* a type annotation, or both.
|
||||
* a type annotation, or both (or none, i.e a non-annotation masquerading as one).
|
||||
*/
|
||||
public AnnotationType annotationTargetType(Attribute.Compound a, Symbol s) {
|
||||
if (!a.type.tsym.isAnnotationType()) {
|
||||
return AnnotationType.NONE;
|
||||
}
|
||||
List<Attribute> targets = annotationTargets(a.type.tsym);
|
||||
return (targets == null) ?
|
||||
AnnotationType.DECLARATION :
|
||||
@ -319,6 +322,8 @@ public class TypeAnnotations {
|
||||
onlyTypeAnnos.append(ta);
|
||||
break;
|
||||
}
|
||||
case NONE: // Error signaled already, just drop the non-annotation.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,17 +344,19 @@ public class Annotate {
|
||||
|
||||
Assert.checkNonNull(c, "Failed to create annotation");
|
||||
|
||||
if (annotated.containsKey(a.type.tsym)) {
|
||||
if (!allowRepeatedAnnos) {
|
||||
log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), Feature.REPEATED_ANNOTATIONS.error(sourceName));
|
||||
if (a.type.tsym.isAnnotationType()) {
|
||||
if (annotated.containsKey(a.type.tsym)) {
|
||||
if (!allowRepeatedAnnos) {
|
||||
log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), Feature.REPEATED_ANNOTATIONS.error(sourceName));
|
||||
}
|
||||
ListBuffer<T> l = annotated.get(a.type.tsym);
|
||||
l = l.append(c);
|
||||
annotated.put(a.type.tsym, l);
|
||||
pos.put(c, a.pos());
|
||||
} else {
|
||||
annotated.put(a.type.tsym, ListBuffer.of(c));
|
||||
pos.put(c, a.pos());
|
||||
}
|
||||
ListBuffer<T> l = annotated.get(a.type.tsym);
|
||||
l = l.append(c);
|
||||
annotated.put(a.type.tsym, l);
|
||||
pos.put(c, a.pos());
|
||||
} else {
|
||||
annotated.put(a.type.tsym, ListBuffer.of(c));
|
||||
pos.put(c, a.pos());
|
||||
}
|
||||
|
||||
// Note: @Deprecated has no effect on local variables and parameters
|
||||
|
@ -2749,7 +2749,7 @@ public class Check {
|
||||
class AnnotationValidator extends TreeScanner {
|
||||
@Override
|
||||
public void visitAnnotation(JCAnnotation tree) {
|
||||
if (!tree.type.isErroneous()) {
|
||||
if (!tree.type.isErroneous() && tree.type.tsym.isAnnotationType()) {
|
||||
super.visitAnnotation(tree);
|
||||
validateAnnotation(tree);
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206325
|
||||
* @summary AssertionError in TypeSymbol.getAnnotationTypeMetadata
|
||||
* @compile/fail/ref=AtNonAnnotationTypeTest.out -XDrawDiagnostics -XDdev AtNonAnnotationTypeTest.java
|
||||
*/
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
class AtNonAnnotationTypeTest<Override extends Annotation> {
|
||||
AtNonAnnotationTypeTest(@Override String foo) {}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
AtNonAnnotationTypeTest.java:10:28: compiler.err.not.annotation.type: Override
|
||||
1 error
|
Loading…
x
Reference in New Issue
Block a user