7042623: Regression: javac silently crash when attributing non-existent annotation

Reviewed-by: mcimadamore
This commit is contained in:
Jonathan Gibbons 2011-06-01 11:25:50 -07:00
parent 0cd0c8c54f
commit 8df816992b
3 changed files with 18 additions and 4 deletions

View File

@ -2240,8 +2240,10 @@ public class Check {
class AnnotationValidator extends TreeScanner {
@Override
public void visitAnnotation(JCAnnotation tree) {
super.visitAnnotation(tree);
validateAnnotation(tree);
if (!tree.type.isErroneous()) {
super.visitAnnotation(tree);
validateAnnotation(tree);
}
}
}
tree.accept(new AnnotationValidator());
@ -2383,8 +2385,6 @@ public class Check {
/** Check an annotation value.
*/
public void validateAnnotation(JCAnnotation a) {
if (a.type.isErroneous()) return;
// collect an inventory of the members (sorted alphabetically)
Set<MethodSymbol> members = new TreeSet<MethodSymbol>(new Comparator<Symbol>() {
public int compare(Symbol t, Symbol t1) {

View File

@ -0,0 +1,12 @@
/*
* @test /nodynamiccopyright/
* @bug 7042623
* @summary Regression: javac silently crash when attributing non-existent annotation
* @compile/fail/ref=T7042623.out -XDrawDiagnostics -XDdev T7042623.java
*/
@interface Defined2 {}
@Undefined1(@Defined2)
class Test1{}

View File

@ -0,0 +1,2 @@
T7042623.java:10:2: compiler.err.cant.resolve: kindname.class, Undefined1, ,
1 error