### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java,v retrieving revision 1.22 diff -u -r1.22 MemberValuePair.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java 31 Mar 2006 22:13:25 -0000 1.22 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java 7 Jul 2006 14:34:48 -0000 @@ -13,9 +13,11 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.impl.Constant; import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; +import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; @@ -141,8 +143,9 @@ final Expression[] expressions = initializer.expressions; if (expressions != null) { for (int i =0, max = expressions.length; i < max; i++) { - if (!(expressions[i] instanceof ClassLiteralAccess)) { - scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, expressions[i]); + Expression currentExpression = expressions[i]; + if (!(currentExpression instanceof ClassLiteralAccess)) { + scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, currentExpression); } } } @@ -153,8 +156,36 @@ } if (leafType.isEnum()) { if (this.value instanceof NullLiteral) { - // TODO (olivier) change message for annotation value must be an *enum* constant scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); + } else if (this.value instanceof ArrayInitializer) { + ArrayInitializer initializer = (ArrayInitializer) this.value; + final Expression[] expressions = initializer.expressions; + if (expressions != null) { + for (int i =0, max = expressions.length; i < max; i++) { + Expression currentExpression = expressions[i]; + if (currentExpression instanceof NullLiteral) { + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression); + } else if (currentExpression instanceof NameReference) { + NameReference nameReference = (NameReference) currentExpression; + final Binding nameReferenceBinding = nameReference.binding; + if (nameReferenceBinding.kind() == Binding.FIELD) { + FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding; + if (!fieldBinding.declaringClass.isEnum()) { + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression); + } + } + } + } + } + } else if (this.value instanceof NameReference) { + NameReference nameReference = (NameReference) this.value; + final Binding nameReferenceBinding = nameReference.binding; + if (nameReferenceBinding.kind() == Binding.FIELD) { + FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding; + if (!fieldBinding.declaringClass.isEnum()) { + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); + } + } } break checkAnnotationMethodType; } Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v retrieving revision 1.207 diff -u -r1.207 messages.properties --- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 2 Jul 2006 12:37:10 -0000 1.207 +++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 7 Jul 2006 14:34:48 -0000 @@ -504,7 +504,7 @@ 610 = Duplicate attribute {0} in annotation @{1} 611 = The attribute {0} is undefined for the annotation type {1} 612 = The value for annotation attribute {0}.{1} must be a class literal -613 = The value for annotation attribute {0}.{1} must be a constant expression +613 = The value for annotation attribute {0}.{1} must be an enum constant expression ###[obsolete] 614 = The annotation field {0}.{1} must be initialized with a constant expression 615 = Illegal modifier for the annotation field {0}.{1}; only public, static & final are permitted 616 = The annotation type {0} cannot override the method {1}.{2}({3})