src/share/classes/com/sun/tools/javac/comp/Check.java

changeset 634
27bae58329d5
parent 632
ea1930f4b789
child 638
d6fe0ea070aa
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Aug 12 19:59:10 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Aug 16 14:56:23 2010 +0100
     1.3 @@ -25,6 +25,7 @@
     1.4  
     1.5  package com.sun.tools.javac.comp;
     1.6  
     1.7 +import com.sun.source.tree.AssignmentTree;
     1.8  import java.util.*;
     1.9  import java.util.Set;
    1.10  
    1.11 @@ -1930,20 +1931,17 @@
    1.12   **************************************************************************/
    1.13  
    1.14      /**
    1.15 -     * Validate annotations in default values
    1.16 +     * Recursively validate annotations values
    1.17       */
    1.18 -    void validateAnnotationDefaultValue(JCTree defaultValue) {
    1.19 -        class DefaultValueValidator extends TreeScanner {
    1.20 +    void validateAnnotationTree(JCTree tree) {
    1.21 +        class AnnotationValidator extends TreeScanner {
    1.22              @Override
    1.23              public void visitAnnotation(JCAnnotation tree) {
    1.24                  super.visitAnnotation(tree);
    1.25                  validateAnnotation(tree);
    1.26              }
    1.27          }
    1.28 -        // defaultValue may be null if an error occurred, so don't bother validating it
    1.29 -        if (defaultValue != null) {
    1.30 -            defaultValue.accept(new DefaultValueValidator());
    1.31 -        }
    1.32 +        tree.accept(new AnnotationValidator());
    1.33      }
    1.34  
    1.35      /** Annotation types are restricted to primitives, String, an
    1.36 @@ -2009,7 +2007,7 @@
    1.37      /** Check an annotation of a symbol.
    1.38       */
    1.39      public void validateAnnotation(JCAnnotation a, Symbol s) {
    1.40 -        validateAnnotation(a);
    1.41 +        validateAnnotationTree(a);
    1.42  
    1.43          if (!annotationApplicable(a, s))
    1.44              log.error(a.pos(), "annotation.type.not.applicable");
    1.45 @@ -2023,7 +2021,7 @@
    1.46      public void validateTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) {
    1.47          if (a.type == null)
    1.48              throw new AssertionError("annotation tree hasn't been attributed yet: " + a);
    1.49 -        validateAnnotation(a);
    1.50 +        validateAnnotationTree(a);
    1.51  
    1.52          if (!isTypeAnnotation(a, isTypeParameter))
    1.53              log.error(a.pos(), "annotation.type.not.applicable");
    1.54 @@ -2141,8 +2139,6 @@
    1.55              if (!members.remove(m))
    1.56                  log.error(assign.lhs.pos(), "duplicate.annotation.member.value",
    1.57                            m.name, a.type);
    1.58 -            if (assign.rhs.getTag() == ANNOTATION)
    1.59 -                validateAnnotation((JCAnnotation)assign.rhs);
    1.60          }
    1.61  
    1.62          // all the remaining ones better have default values

mercurial