langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
changeset 6347 947437d52cc1
parent 6345 7d98c298aafd
child 6351 84c44db80d06
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Aug 12 19:59:10 2010 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Aug 16 14:56:23 2010 +0100
@@ -25,6 +25,7 @@
 
 package com.sun.tools.javac.comp;
 
+import com.sun.source.tree.AssignmentTree;
 import java.util.*;
 import java.util.Set;
 
@@ -1930,20 +1931,17 @@
  **************************************************************************/
 
     /**
-     * Validate annotations in default values
+     * Recursively validate annotations values
      */
-    void validateAnnotationDefaultValue(JCTree defaultValue) {
-        class DefaultValueValidator extends TreeScanner {
+    void validateAnnotationTree(JCTree tree) {
+        class AnnotationValidator extends TreeScanner {
             @Override
             public void visitAnnotation(JCAnnotation tree) {
                 super.visitAnnotation(tree);
                 validateAnnotation(tree);
             }
         }
-        // defaultValue may be null if an error occurred, so don't bother validating it
-        if (defaultValue != null) {
-            defaultValue.accept(new DefaultValueValidator());
-        }
+        tree.accept(new AnnotationValidator());
     }
 
     /** Annotation types are restricted to primitives, String, an
@@ -2009,7 +2007,7 @@
     /** Check an annotation of a symbol.
      */
     public void validateAnnotation(JCAnnotation a, Symbol s) {
-        validateAnnotation(a);
+        validateAnnotationTree(a);
 
         if (!annotationApplicable(a, s))
             log.error(a.pos(), "annotation.type.not.applicable");
@@ -2023,7 +2021,7 @@
     public void validateTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) {
         if (a.type == null)
             throw new AssertionError("annotation tree hasn't been attributed yet: " + a);
-        validateAnnotation(a);
+        validateAnnotationTree(a);
 
         if (!isTypeAnnotation(a, isTypeParameter))
             log.error(a.pos(), "annotation.type.not.applicable");
@@ -2141,8 +2139,6 @@
             if (!members.remove(m))
                 log.error(assign.lhs.pos(), "duplicate.annotation.member.value",
                           m.name, a.type);
-            if (assign.rhs.getTag() == ANNOTATION)
-                validateAnnotation((JCAnnotation)assign.rhs);
         }
 
         // all the remaining ones better have default values