Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 51098 Details for
Bug 149751
Enum-valued annotation element handles non-enum constant badly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New patch for 3.2 maintenance
patch_149751.txt (text/plain), 5.40 KB, created by
Olivier Thomann
on 2006-09-28 12:04:45 EDT
(
hide
)
Description:
New patch for 3.2 maintenance
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-09-28 12:04:45 EDT
Size:
5.40 KB
patch
obsolete
>### 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 28 Sep 2006 16:07: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; > >@@ -132,7 +134,11 @@ > } > } > } else if (this.value.constant == Constant.NotAConstant) { >- scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); >+ if (valueType.isArrayType()) { >+ scope.problemReporter().annotationValueMustBeArrayInitializer(this.value); >+ } else { >+ scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); >+ } > } > 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); >+ } 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()) { >+ if (!fieldBinding.type.isArrayType()) { >+ scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); >+ } else { >+ scope.problemReporter().annotationValueMustBeArrayInitializer(this.value); >+ } >+ } >+ } > } > break checkAnnotationMethodType; > } >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.311 >diff -u -r1.311 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 10 Apr 2006 19:04:00 -0000 1.311 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 28 Sep 2006 16:07:56 -0000 >@@ -601,7 +601,7 @@ > value.sourceEnd); > } > public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value) { >- String str = new String(name); >+ String str = new String(name); > this.handle( > IProblem.AnnotationValueMustBeConstant, > new String[] { new String(annotationType.readableName()), str },
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 149751
:
45920
|
45921
|
49948
|
49974
|
49975
|
50002
|
50003
|
50036
| 51098 |
51099