7042623: Regression: javac silently crash when attributing non-existent annotation
authorjjg
Wed, 01 Jun 2011 11:25:50 -0700
changeset 9814 978b696e85ad
parent 9813 74626f128287
child 9815 e4b5be572a36
7042623: Regression: javac silently crash when attributing non-existent annotation Reviewed-by: mcimadamore
langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
langtools/test/tools/javac/T7042623.java
langtools/test/tools/javac/T7042623.out
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri May 27 15:02:39 2011 -0700
+++ b/langtools/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<MethodSymbol> members = new TreeSet<MethodSymbol>(new Comparator<Symbol>() {
             public int compare(Symbol t, Symbol t1) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/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{}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/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