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 131335 Details for
Bug 271561
JavaModelException when accessing an array of nested annotations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_271561.txt (text/plain), 7.02 KB, created by
Olivier Thomann
on 2009-04-08 15:52:16 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2009-04-08 15:52:16 EDT
Size:
7.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/ClassFileInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java,v >retrieving revision 1.44 >diff -u -r1.44 ClassFileInfo.java >--- model/org/eclipse/jdt/internal/core/ClassFileInfo.java 7 Mar 2009 01:08:08 -0000 1.44 >+++ model/org/eclipse/jdt/internal/core/ClassFileInfo.java 8 Apr 2009 19:51:40 -0000 >@@ -57,12 +57,49 @@ > private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo) { > char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.')); > Annotation annotation = new Annotation(parent, new String(typeName)); >+ while (newElements.containsKey(annotation)) { >+ annotation.occurrenceCount++; >+ } >+ newElements.put(annotation, annotationInfo); >+ IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs(); >+ for (int i = 0, length = pairs.length; i < length; i++) { >+ Object value = pairs[i].getValue(); >+ if (value instanceof IBinaryAnnotation) { >+ generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value, new String(pairs[i].getName())); >+ } else if (value instanceof Object[]) { >+ // if the value is an array, it can have no more than 1 dimension - no need to recurse >+ Object[] valueArray = (Object[]) value; >+ for (int j = 0, valueArrayLength = valueArray.length; j < valueArrayLength; j++) { >+ Object nestedValue = valueArray[j]; >+ if (nestedValue instanceof IBinaryAnnotation) { >+ generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) nestedValue, new String(pairs[i].getName())); >+ } >+ } >+ } >+ } >+} >+private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo, String memberName) { >+ char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.')); >+ Annotation annotation = new Annotation(parent, new String(typeName)); >+ annotation.memberValueName = memberName; >+ while (newElements.containsKey(annotation)) { >+ annotation.occurrenceCount++; >+ } > newElements.put(annotation, annotationInfo); > IBinaryElementValuePair[] pairs = annotationInfo.getElementValuePairs(); > for (int i = 0, length = pairs.length; i < length; i++) { > Object value = pairs[i].getValue(); > if (value instanceof IBinaryAnnotation) { >- generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value); >+ generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) value, new String(pairs[i].getName())); >+ } else if (value instanceof Object[]) { >+ // if the value is an array, it can have no more than 1 dimension - no need to recurse >+ Object[] valueArray = (Object[]) value; >+ for (int j = 0, valueArrayLength = valueArray.length; j < valueArrayLength; j++) { >+ Object nestedValue = valueArray[j]; >+ if (nestedValue instanceof IBinaryAnnotation) { >+ generateAnnotationInfo(annotation, newElements, (IBinaryAnnotation) nestedValue, new String(pairs[i].getName())); >+ } >+ } > } > } > } >Index: model/org/eclipse/jdt/internal/core/Annotation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Annotation.java,v >retrieving revision 1.5 >diff -u -r1.5 Annotation.java >--- model/org/eclipse/jdt/internal/core/Annotation.java 7 Mar 2009 01:08:08 -0000 1.5 >+++ model/org/eclipse/jdt/internal/core/Annotation.java 8 Apr 2009 19:51:40 -0000 >@@ -26,6 +26,8 @@ > public static final IMemberValuePair[] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair[0]; > > protected String name; >+ // require to distinguish same annotations in different member value pairs >+ public String memberValueName; > > public Annotation(JavaElement parent, String name) { > super(parent); >@@ -33,7 +35,16 @@ > } > > public boolean equals(Object o) { >- if (!(o instanceof Annotation)) return false; >+ if (!(o instanceof Annotation)) { >+ return false; >+ } >+ Annotation other = (Annotation) o; >+ if (this.memberValueName == null) { >+ if (other.memberValueName != null) >+ return false; >+ } else if (!this.memberValueName.equals(other.memberValueName)) { >+ return false; >+ } > return super.equals(o); > } > >@@ -107,6 +118,14 @@ > return ((JavaElement)getParent()).getClassFile(); > } > >+ public int hashCode() { >+ final int prime = 31; >+ int result = super.hashCode(); >+ result = prime * result + ((this.memberValueName == null) ? 0 : this.memberValueName.hashCode()); >+ result = prime * result + this.name.hashCode(); >+ return result; >+ } >+ > protected void toStringName(StringBuffer buffer) { > buffer.append('@'); > buffer.append(getElementName()); >Index: model/org/eclipse/jdt/internal/core/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java,v >retrieving revision 1.129 >diff -u -r1.129 Util.java >--- model/org/eclipse/jdt/internal/core/util/Util.java 7 Mar 2009 00:58:54 -0000 1.129 >+++ model/org/eclipse/jdt/internal/core/util/Util.java 8 Apr 2009 19:51:42 -0000 >@@ -3065,7 +3065,7 @@ > } > return typeArguments; > } >- public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation) { >+ public static Annotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation) { > char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.')); > return new Annotation(parent, new String(typeName)); > } >@@ -3075,7 +3075,9 @@ > return getAnnotationMemberValue(memberValuePair, (Constant) binaryValue); > } else if (binaryValue instanceof IBinaryAnnotation) { > memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION; >- return getAnnotation(parent, (IBinaryAnnotation) binaryValue); >+ Annotation annotation = getAnnotation(parent, (IBinaryAnnotation) binaryValue); >+ annotation.memberValueName = memberValuePair.getMemberName(); >+ return annotation; > } else if (binaryValue instanceof ClassSignature) { > memberValuePair.valueKind = IMemberValuePair.K_CLASS; > char[] className = Signature.toCharArray(CharOperation.replaceOnCopy(((ClassSignature) binaryValue).getTypeName(), '/', '.')); >@@ -3098,6 +3100,15 @@ > // values are heterogeneous, value kind is thus unknown > memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; > } >+ if (value instanceof Annotation) { >+ Annotation annotation = (Annotation) value; >+ annotation.memberValueName = memberValuePair.getMemberName(); >+ for (int j = 0; j < i; j++) { >+ if (annotation.equals(values[j])) { >+ annotation.occurrenceCount++; >+ } >+ } >+ } > values[i] = value; > } > if (memberValuePair.valueKind == -1)
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 271561
:
131221
|
131226
|
131310
|
131318
| 131335