View | Details | Raw Unified | Return to bug 149751 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java (-3 / +34 lines)
Lines 13-21 Link Here
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.impl.Constant;
14
import org.eclipse.jdt.internal.compiler.impl.Constant;
15
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
15
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
16
import org.eclipse.jdt.internal.compiler.lookup.Binding;
16
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
17
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
17
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
18
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
18
import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
19
import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
20
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
19
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
21
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
20
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
22
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
21
23
Lines 141-148 Link Here
141
						final Expression[] expressions = initializer.expressions;
143
						final Expression[] expressions = initializer.expressions;
142
						if (expressions != null) {
144
						if (expressions != null) {
143
							for (int i =0, max = expressions.length; i < max; i++) {
145
							for (int i =0, max = expressions.length; i < max; i++) {
144
								if (!(expressions[i] instanceof ClassLiteralAccess)) {
146
								Expression currentExpression = expressions[i];
145
									scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, expressions[i]);
147
								if (!(currentExpression instanceof ClassLiteralAccess)) {
148
									scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, currentExpression);
146
								}
149
								}
147
							}
150
							}
148
						}
151
						}
Lines 153-160 Link Here
153
			}
156
			}
154
			if (leafType.isEnum()) {
157
			if (leafType.isEnum()) {
155
				if (this.value instanceof NullLiteral) {
158
				if (this.value instanceof NullLiteral) {
156
					// TODO (olivier) change message for annotation value must be an *enum* constant
157
					scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value);
159
					scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value);
160
				} else if (this.value instanceof ArrayInitializer) {
161
					ArrayInitializer initializer = (ArrayInitializer) this.value;
162
					final Expression[] expressions = initializer.expressions;
163
					if (expressions != null) {
164
						for (int i =0, max = expressions.length; i < max; i++) {
165
							Expression currentExpression = expressions[i];
166
							if (currentExpression instanceof NullLiteral) {
167
								scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression);
168
							} else if (currentExpression instanceof NameReference) {
169
								NameReference nameReference = (NameReference) currentExpression;
170
								final Binding nameReferenceBinding = nameReference.binding;
171
								if (nameReferenceBinding.kind() == Binding.FIELD) {
172
									FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding;
173
									if (!fieldBinding.declaringClass.isEnum()) {
174
										scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression);
175
									}
176
								}
177
							}
178
						}
179
					}
180
				} else if (this.value instanceof NameReference) {
181
					NameReference nameReference = (NameReference) this.value;
182
					final Binding nameReferenceBinding = nameReference.binding;
183
					if (nameReferenceBinding.kind() == Binding.FIELD) {
184
						FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding;
185
						if (!fieldBinding.declaringClass.isEnum()) {
186
							scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value);
187
						}
188
					}
158
				}
189
				}
159
				break checkAnnotationMethodType;
190
				break checkAnnotationMethodType;
160
			}
191
			}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (-1 / +1 lines)
Lines 504-510 Link Here
504
610 = Duplicate attribute {0} in annotation @{1}
504
610 = Duplicate attribute {0} in annotation @{1}
505
611 = The attribute {0} is undefined for the annotation type {1}
505
611 = The attribute {0} is undefined for the annotation type {1}
506
612 = The value for annotation attribute {0}.{1} must be a class literal
506
612 = The value for annotation attribute {0}.{1} must be a class literal
507
613 = The value for annotation attribute {0}.{1} must be a constant expression
507
613 = The value for annotation attribute {0}.{1} must be an enum constant expression
508
###[obsolete] 614 = The annotation field {0}.{1} must be initialized with a constant expression
508
###[obsolete] 614 = The annotation field {0}.{1} must be initialized with a constant expression
509
615 = Illegal modifier for the annotation field {0}.{1}; only public, static & final are permitted
509
615 = Illegal modifier for the annotation field {0}.{1}; only public, static & final are permitted
510
616 = The annotation type {0} cannot override the method {1}.{2}({3})
510
616 = The annotation type {0} cannot override the method {1}.{2}({3})

Return to bug 149751