changeset 1047:6762754eb7c0

7042623: Regression: javac silently crash when attributing non-existent annotation Reviewed-by: mcimadamore
author jjg
date Wed, 01 Jun 2011 11:25:50 -0700
parents 6211df69f7e0
children c455e2ae5c93
files src/share/classes/com/sun/tools/javac/comp/Check.java test/tools/javac/T7042623.java test/tools/javac/T7042623.out
diffstat 3 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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<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/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/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