# HG changeset patch # User jjg # Date 1306952750 25200 # Node ID 6762754eb7c03c4135038640ea55557a8805a496 # Parent 6211df69f7e0b5fd22f19ad2d760edbc78074d45 7042623: Regression: javac silently crash when attributing non-existent annotation Reviewed-by: mcimadamore diff -r 6211df69f7e0 -r 6762754eb7c0 src/share/classes/com/sun/tools/javac/comp/Check.java --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri May 27 15:02:39 2011 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jun 01 11:25:50 2011 -0700 @@ -2240,8 +2240,10 @@ 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 @@ /** Check an annotation value. */ public void validateAnnotation(JCAnnotation a) { - if (a.type.isErroneous()) return; - // collect an inventory of the members (sorted alphabetically) Set members = new TreeSet(new Comparator() { public int compare(Symbol t, Symbol t1) { diff -r 6211df69f7e0 -r 6762754eb7c0 test/tools/javac/T7042623.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7042623.java Wed Jun 01 11:25:50 2011 -0700 @@ -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{} + diff -r 6211df69f7e0 -r 6762754eb7c0 test/tools/javac/T7042623.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7042623.out Wed Jun 01 11:25:50 2011 -0700 @@ -0,0 +1,2 @@ +T7042623.java:10:2: compiler.err.cant.resolve: kindname.class, Undefined1, , +1 error