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

Wed, 01 Jun 2011 11:25:50 -0700

author
jjg
date
Wed, 01 Jun 2011 11:25:50 -0700
changeset 1017
6762754eb7c0
parent 1016
6211df69f7e0
child 1018
c455e2ae5c93

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

src/share/classes/com/sun/tools/javac/comp/Check.java file | annotate | diff | comparison | revisions
test/tools/javac/T7042623.java file | annotate | diff | comparison | revisions
test/tools/javac/T7042623.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri May 27 15:02:39 2011 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jun 01 11:25:50 2011 -0700
     1.3 @@ -2240,8 +2240,10 @@
     1.4          class AnnotationValidator extends TreeScanner {
     1.5              @Override
     1.6              public void visitAnnotation(JCAnnotation tree) {
     1.7 -                super.visitAnnotation(tree);
     1.8 -                validateAnnotation(tree);
     1.9 +                if (!tree.type.isErroneous()) {
    1.10 +                    super.visitAnnotation(tree);
    1.11 +                    validateAnnotation(tree);
    1.12 +                }
    1.13              }
    1.14          }
    1.15          tree.accept(new AnnotationValidator());
    1.16 @@ -2383,8 +2385,6 @@
    1.17      /** Check an annotation value.
    1.18       */
    1.19      public void validateAnnotation(JCAnnotation a) {
    1.20 -        if (a.type.isErroneous()) return;
    1.21 -
    1.22          // collect an inventory of the members (sorted alphabetically)
    1.23          Set<MethodSymbol> members = new TreeSet<MethodSymbol>(new Comparator<Symbol>() {
    1.24              public int compare(Symbol t, Symbol t1) {
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/T7042623.java	Wed Jun 01 11:25:50 2011 -0700
     2.3 @@ -0,0 +1,12 @@
     2.4 +/*
     2.5 + * @test /nodynamiccopyright/
     2.6 + * @bug 7042623
     2.7 + * @summary Regression: javac silently crash when attributing non-existent annotation
     2.8 + * @compile/fail/ref=T7042623.out -XDrawDiagnostics -XDdev T7042623.java
     2.9 + */
    2.10 +
    2.11 +@interface Defined2 {}
    2.12 +
    2.13 +@Undefined1(@Defined2)
    2.14 +class Test1{}
    2.15 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/T7042623.out	Wed Jun 01 11:25:50 2011 -0700
     3.3 @@ -0,0 +1,2 @@
     3.4 +T7042623.java:10:2: compiler.err.cant.resolve: kindname.class, Undefined1, , 
     3.5 +1 error

mercurial