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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+21 lines)
Lines 75-80 Link Here
75
 *     IBM Corporation - added the following constants
75
 *     IBM Corporation - added the following constants
76
 *								   ParameterAssignment
76
 *								   ParameterAssignment
77
 *								   FallthroughCase
77
 *								   FallthroughCase
78
 *     IBM Corporation - added the following constants
79
 *                                 UnusedLabel
80
 *                                 UnnecessaryNLSTag
81
 *                                 LocalVariableMayBeNull
82
 *                                 EnumConstantsCannotBeSurroundedByParenthesis
83
 *                                 JavadocMissingIdentifier
84
 *                                 JavadocNonStaticTypeFromStaticInvocation
85
 *                                 RawTypeReference
86
 *                                 NoAdditionalBoundAfterTypeVariable
87
 *                                 UnsafeGenericArrayForVarargs
88
 *                                 IllegalAccessFromTypeVariable
89
 *                                 AnnotationValueMustBeArrayInitializer
90
 *                                 InvalidEncoding
91
 *                                 CannotReadSource
92
 *                                 EnumStaticFieldInInInitializerContext
93
 *                                 ExternalProblemNotFixable
94
 *                                 ExternalProblemFixable
95
 *     IBM Corporation - added the following constants
96
 *                                 AnnotationValueMustBeAnEnumConstant
78
 *******************************************************************************/
97
 *******************************************************************************/
79
package org.eclipse.jdt.core.compiler;
98
package org.eclipse.jdt.core.compiler;
80
 
99
 
Lines 1097-1102 Link Here
1097
	int UnhandledWarningToken = Internal + 631;
1116
	int UnhandledWarningToken = Internal + 631;
1098
	/** @since 3.2 */
1117
	/** @since 3.2 */
1099
	int AnnotationValueMustBeArrayInitializer = Internal + 632;
1118
	int AnnotationValueMustBeArrayInitializer = Internal + 632;
1119
	/** @since 3.3 */
1120
	int AnnotationValueMustBeAnEnumConstant = Internal + 633;
1100
	
1121
	
1101
	/**
1122
	/**
1102
	 * Corrupted binaries
1123
	 * Corrupted binaries
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (-1 / +2 lines)
Lines 523-529 Link Here
523
629 = The deprecated method {0}({1}) of type {2} should be annotated with @Deprecated
523
629 = The deprecated method {0}({1}) of type {2} should be annotated with @Deprecated
524
630 = The deprecated type {0} should be annotated with @Deprecated
524
630 = The deprecated type {0} should be annotated with @Deprecated
525
631 = Unhandled warning token {0}
525
631 = Unhandled warning token {0}
526
632 = The array creation is unnecessary in an annotation value; only an array initializer is allowed
526
632 = The value for annotation attribute {0}.{1} must be an array initializer
527
633 = The value for annotation attribute {0}.{1} must be an enum constant expression
527
528
528
### CORRUPTED BINARIES
529
### CORRUPTED BINARIES
529
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
530
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-14 / +24 lines)
Lines 585-597 Link Here
585
		value.sourceStart,
585
		value.sourceStart,
586
		value.sourceEnd);
586
		value.sourceEnd);
587
}
587
}
588
public void annotationValueMustBeArrayInitializer(Expression value) {
588
public void annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value) {
589
	String str = new String(name);
589
	this.handle(
590
	this.handle(
590
			IProblem.AnnotationValueMustBeArrayInitializer,
591
    	IProblem.AnnotationValueMustBeArrayInitializer,
591
			NoArgument,
592
		new String[] { new String(annotationType.readableName()), str },
592
			NoArgument,
593
		new String[] { new String(annotationType.shortReadableName()), str},
593
			value.sourceStart,
594
    	value.sourceStart,
594
			value.sourceEnd);
595
    	value.sourceEnd);
595
}
596
}
596
public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) {
597
public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) {
597
	String str = new String(name);
598
	String str = new String(name);
Lines 602-615 Link Here
602
		value.sourceStart,
603
		value.sourceStart,
603
		value.sourceEnd);
604
		value.sourceEnd);
604
}
605
}
605
public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value) {
606
public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum) {
606
	String str = 	new String(name);
607
	String str = new String(name);
607
	this.handle(
608
	if (isEnum) {
608
		IProblem.AnnotationValueMustBeConstant,
609
    	this.handle(
609
		new String[] { new String(annotationType.readableName()), str },
610
    		IProblem.AnnotationValueMustBeAnEnumConstant,
610
		new String[] { new String(annotationType.shortReadableName()), str},
611
    		new String[] { new String(annotationType.readableName()), str },
611
		value.sourceStart,
612
    		new String[] { new String(annotationType.shortReadableName()), str},
612
		value.sourceEnd);
613
    		value.sourceStart,
614
    		value.sourceEnd);
615
	} else {
616
    	this.handle(
617
    		IProblem.AnnotationValueMustBeConstant,
618
    		new String[] { new String(annotationType.readableName()), str },
619
    		new String[] { new String(annotationType.shortReadableName()), str},
620
    		value.sourceStart,
621
    		value.sourceEnd);
622
    }
613
}
623
}
614
public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) {
624
public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) {
615
	this.handle(
625
	this.handle(
(-)buildnotes_jdt-core.html (-2 / +3 lines)
Lines 56-62 Link Here
56
56
57
<h3>Problem Reports Fixed</h3>
57
<h3>Problem Reports Fixed</h3>
58
58
59
60
<a name="v_712"></a>
59
<a name="v_712"></a>
61
<p><hr><h1>
60
<p><hr><h1>
62
Eclipse Platform Build Notes<br>
61
Eclipse Platform Build Notes<br>
Lines 247-253 Link Here
247
</ul>
246
</ul>
248
247
249
<h3>Problem Reports Fixed</h3>
248
<h3>Problem Reports Fixed</h3>
250
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=148224">148224</a>
249
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=151756">151756</a>
250
[compiler] unverifiable bytecode created with cvs head compiler
251
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=148224">148224</a>
251
AST API request: have binding for int, need int[], int[][] ....
252
AST API request: have binding for int, need int[], int[][] ....
252
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=153303">153303</a>
253
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=153303">153303</a>
253
IBinding.getAnnotations() returns array with null element
254
IBinding.getAnnotations() returns array with null element
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java (-7 / +46 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 76-82 Link Here
76
			ArrayInitializer initializer = (ArrayInitializer) this.value;
78
			ArrayInitializer initializer = (ArrayInitializer) this.value;
77
			valueType = initializer.resolveTypeExpecting(scope, this.binding.returnType);
79
			valueType = initializer.resolveTypeExpecting(scope, this.binding.returnType);
78
		} else if (this.value instanceof ArrayAllocationExpression) {
80
		} else if (this.value instanceof ArrayAllocationExpression) {
79
			scope.problemReporter().annotationValueMustBeArrayInitializer(this.value);
81
			scope.problemReporter().annotationValueMustBeArrayInitializer(this.binding.declaringClass, this.name, this.value);
80
			this.value.resolveType(scope);
82
			this.value.resolveType(scope);
81
			valueType = null; // no need to pursue
83
			valueType = null; // no need to pursue
82
		} else {
84
		} else {
Lines 127-138 Link Here
127
						if (expressions != null) {
129
						if (expressions != null) {
128
							for (int i =0, max = expressions.length; i < max; i++) {
130
							for (int i =0, max = expressions.length; i < max; i++) {
129
								if (expressions[i].constant == Constant.NotAConstant) {
131
								if (expressions[i].constant == Constant.NotAConstant) {
130
									scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, expressions[i]);
132
									scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, expressions[i], false);
131
								}
133
								}
132
							}
134
							}
133
						}
135
						}
134
					} else if (this.value.constant == Constant.NotAConstant) {
136
					} else if (this.value.constant == Constant.NotAConstant) {
135
						scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value);
137
						if (valueType.isArrayType()) {
138
							scope.problemReporter().annotationValueMustBeArrayInitializer(this.binding.declaringClass, this.name, this.value);
139
						} else {
140
							scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, false);
141
						}
136
					}
142
					}
137
					break checkAnnotationMethodType;
143
					break checkAnnotationMethodType;
138
				case T_JavaLangClass :
144
				case T_JavaLangClass :
Lines 141-148 Link Here
141
						final Expression[] expressions = initializer.expressions;
147
						final Expression[] expressions = initializer.expressions;
142
						if (expressions != null) {
148
						if (expressions != null) {
143
							for (int i =0, max = expressions.length; i < max; i++) {
149
							for (int i =0, max = expressions.length; i < max; i++) {
144
								if (!(expressions[i] instanceof ClassLiteralAccess)) {
150
								Expression currentExpression = expressions[i];
145
									scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, expressions[i]);
151
								if (!(currentExpression instanceof ClassLiteralAccess)) {
152
									scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, currentExpression);
146
								}
153
								}
147
							}
154
							}
148
						}
155
						}
Lines 153-160 Link Here
153
			}
160
			}
154
			if (leafType.isEnum()) {
161
			if (leafType.isEnum()) {
155
				if (this.value instanceof NullLiteral) {
162
				if (this.value instanceof NullLiteral) {
156
					// TODO (olivier) change message for annotation value must be an *enum* constant
163
					scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, true);
157
					scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value);
164
				} else if (this.value instanceof ArrayInitializer) {
165
					ArrayInitializer initializer = (ArrayInitializer) this.value;
166
					final Expression[] expressions = initializer.expressions;
167
					if (expressions != null) {
168
						for (int i =0, max = expressions.length; i < max; i++) {
169
							Expression currentExpression = expressions[i];
170
							if (currentExpression instanceof NullLiteral) {
171
								scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression, true);
172
							} else if (currentExpression instanceof NameReference) {
173
								NameReference nameReference = (NameReference) currentExpression;
174
								final Binding nameReferenceBinding = nameReference.binding;
175
								if (nameReferenceBinding.kind() == Binding.FIELD) {
176
									FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding;
177
									if (!fieldBinding.declaringClass.isEnum()) {
178
										scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression, true);
179
									}
180
								}
181
							}
182
						}
183
					}
184
				} else if (this.value instanceof NameReference) {
185
					NameReference nameReference = (NameReference) this.value;
186
					final Binding nameReferenceBinding = nameReference.binding;
187
					if (nameReferenceBinding.kind() == Binding.FIELD) {
188
						FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding;
189
						if (!fieldBinding.declaringClass.isEnum()) {
190
							if (!fieldBinding.type.isArrayType()) {
191
								scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, true);
192
							} else {
193
								scope.problemReporter().annotationValueMustBeArrayInitializer(this.binding.declaringClass, this.name, this.value);
194
							}
195
						}
196
					}
158
				}
197
				}
159
				break checkAnnotationMethodType;
198
				break checkAnnotationMethodType;
160
			}
199
			}

Return to bug 149751