### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v retrieving revision 1.179 diff -u -r1.179 IProblem.java --- compiler/org/eclipse/jdt/core/compiler/IProblem.java 2 Jul 2006 12:37:10 -0000 1.179 +++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 12 Sep 2006 19:09:55 -0000 @@ -75,6 +75,25 @@ * IBM Corporation - added the following constants * ParameterAssignment * FallthroughCase + * IBM Corporation - added the following constants + * UnusedLabel + * UnnecessaryNLSTag + * LocalVariableMayBeNull + * EnumConstantsCannotBeSurroundedByParenthesis + * JavadocMissingIdentifier + * JavadocNonStaticTypeFromStaticInvocation + * RawTypeReference + * NoAdditionalBoundAfterTypeVariable + * UnsafeGenericArrayForVarargs + * IllegalAccessFromTypeVariable + * AnnotationValueMustBeArrayInitializer + * InvalidEncoding + * CannotReadSource + * EnumStaticFieldInInInitializerContext + * ExternalProblemNotFixable + * ExternalProblemFixable + * IBM Corporation - added the following constants + * AnnotationValueMustBeAnEnumConstant *******************************************************************************/ package org.eclipse.jdt.core.compiler; @@ -1097,6 +1116,8 @@ int UnhandledWarningToken = Internal + 631; /** @since 3.2 */ int AnnotationValueMustBeArrayInitializer = Internal + 632; + /** @since 3.3 */ + int AnnotationValueMustBeAnEnumConstant = Internal + 633; /** * Corrupted binaries 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 12 Sep 2006 19:09:56 -0000 @@ -523,7 +523,8 @@ 629 = The deprecated method {0}({1}) of type {2} should be annotated with @Deprecated 630 = The deprecated type {0} should be annotated with @Deprecated 631 = Unhandled warning token {0} -632 = The array creation is unnecessary in an annotation value; only an array initializer is allowed +632 = The value for annotation attribute {0}.{1} must be an array initializer +633 = The value for annotation attribute {0}.{1} must be an enum constant expression ### CORRUPTED BINARIES 700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2} Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.316 diff -u -r1.316 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 4 Jul 2006 10:03:12 -0000 1.316 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 12 Sep 2006 19:09:56 -0000 @@ -585,13 +585,14 @@ value.sourceStart, value.sourceEnd); } -public void annotationValueMustBeArrayInitializer(Expression value) { +public void annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value) { + String str = new String(name); this.handle( - IProblem.AnnotationValueMustBeArrayInitializer, - NoArgument, - NoArgument, - value.sourceStart, - value.sourceEnd); + IProblem.AnnotationValueMustBeArrayInitializer, + new String[] { new String(annotationType.readableName()), str }, + new String[] { new String(annotationType.shortReadableName()), str}, + value.sourceStart, + value.sourceEnd); } public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) { String str = new String(name); @@ -602,14 +603,23 @@ value.sourceStart, value.sourceEnd); } -public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value) { - String str = new String(name); - this.handle( - IProblem.AnnotationValueMustBeConstant, - new String[] { new String(annotationType.readableName()), str }, - new String[] { new String(annotationType.shortReadableName()), str}, - value.sourceStart, - value.sourceEnd); +public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum) { + String str = new String(name); + if (isEnum) { + this.handle( + IProblem.AnnotationValueMustBeAnEnumConstant, + new String[] { new String(annotationType.readableName()), str }, + new String[] { new String(annotationType.shortReadableName()), str}, + value.sourceStart, + value.sourceEnd); + } else { + this.handle( + IProblem.AnnotationValueMustBeConstant, + new String[] { new String(annotationType.readableName()), str }, + new String[] { new String(annotationType.shortReadableName()), str}, + value.sourceStart, + value.sourceEnd); + } } public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) { this.handle( Index: buildnotes_jdt-core.html =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v retrieving revision 1.5403 diff -u -r1.5403 buildnotes_jdt-core.html --- buildnotes_jdt-core.html 12 Sep 2006 12:02:51 -0000 1.5403 +++ buildnotes_jdt-core.html 12 Sep 2006 19:09:55 -0000 @@ -56,7 +56,6 @@

Problem Reports Fixed

-


Eclipse Platform Build Notes
@@ -247,7 +246,9 @@

Problem Reports Fixed

-148224 +151756 +[compiler] unverifiable bytecode created with cvs head compiler +
148224 AST API request: have binding for int, need int[], int[][] ....
153303 IBinding.getAnnotations() returns array with null element 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 12 Sep 2006 19:09:55 -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; @@ -76,7 +78,7 @@ ArrayInitializer initializer = (ArrayInitializer) this.value; valueType = initializer.resolveTypeExpecting(scope, this.binding.returnType); } else if (this.value instanceof ArrayAllocationExpression) { - scope.problemReporter().annotationValueMustBeArrayInitializer(this.value); + scope.problemReporter().annotationValueMustBeArrayInitializer(this.binding.declaringClass, this.name, this.value); this.value.resolveType(scope); valueType = null; // no need to pursue } else { @@ -127,12 +129,16 @@ if (expressions != null) { for (int i =0, max = expressions.length; i < max; i++) { if (expressions[i].constant == Constant.NotAConstant) { - scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, expressions[i]); + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, expressions[i], false); } } } } else if (this.value.constant == Constant.NotAConstant) { - scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); + if (valueType.isArrayType()) { + scope.problemReporter().annotationValueMustBeArrayInitializer(this.binding.declaringClass, this.name, this.value); + } else { + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, false); + } } break checkAnnotationMethodType; case T_JavaLangClass : @@ -141,8 +147,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 +160,40 @@ } 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); + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, true); + } 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, true); + } 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, true); + } + } + } + } + } + } 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()) { + if (!fieldBinding.type.isArrayType()) { + scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, true); + } else { + scope.problemReporter().annotationValueMustBeArrayInitializer(this.binding.declaringClass, this.name, this.value); + } + } + } } break checkAnnotationMethodType; }