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 51753 Details for
Bug 155115
UnresolvedReferenceBindings surfacing through DOM AST
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Reduced fix for the 3.2 maintenance branch, plus test cases.
org.eclipse.jdt.core_03.txt (text/plain), 10.36 KB, created by
Maxime Daniel
on 2006-10-11 09:12:02 EDT
(
hide
)
Description:
Reduced fix for the 3.2 maintenance branch, plus test cases.
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2006-10-11 09:12:02 EDT
Size:
10.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedAnnotationBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedAnnotationBinding.java,v >retrieving revision 1.2 >diff -u -r1.2 UnresolvedAnnotationBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedAnnotationBinding.java 29 Mar 2006 02:45:27 -0000 1.2 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedAnnotationBinding.java 11 Oct 2006 13:09:42 -0000 >@@ -12,6 +12,7 @@ > > public class UnresolvedAnnotationBinding extends AnnotationBinding { > private LookupEnvironment env; >+ private boolean typeUnresolved = true; > > UnresolvedAnnotationBinding(ReferenceBinding type, ElementValuePair[] pairs, LookupEnvironment env) { > super(type, pairs); >@@ -19,20 +20,37 @@ > } > > public ReferenceBinding getAnnotationType() { >- // the type is resolved when requested >- if (this.env != null) { >- // annotation type are never parameterized >+ if (this.typeUnresolved) { // the type is resolved when requested > this.type = BinaryTypeBinding.resolveType(this.type, this.env, false); >- this.env = null; >- setMethodBindings(); >+ // annotation type are never parameterized >+ this.typeUnresolved = false; > } > return this.type; > } > > public ElementValuePair[] getElementValuePairs() { >- if (this.env != null) >- getAnnotationType(); // resolve the annotation type & method bindings of each pair >- >+ if (this.env != null) { >+ if (this.typeUnresolved) { >+ getAnnotationType(); // resolve the annotation type >+ } >+ // resolve method binding and value type (if unresolved) for each pair >+ for (int i = this.pairs.length; --i >= 0;) { >+ ElementValuePair pair = this.pairs[i]; >+ MethodBinding[] methods = this.type.getMethods(pair.getName()); >+ // there should be exactly one since the type is an annotation type. >+ if (methods != null && methods.length == 1) { >+ pair.setMethodBinding(methods[0]); >+ } // else silently leave a null there >+ Object value = pair.getValue(); >+ if (value instanceof UnresolvedReferenceBinding) { >+ pair.setValue(((UnresolvedReferenceBinding) value). >+ resolve(this.env, false)); >+ // no parameterized types in annotation values >+ } // do nothing for UnresolvedAnnotationBinding-s, since their >+ // content is only accessed through get* methods >+ } >+ this.env = null; >+ } > return this.pairs; > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java,v >retrieving revision 1.2 >diff -u -r1.2 ElementValuePair.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java 29 Mar 2006 02:40:11 -0000 1.2 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java 11 Oct 2006 13:09:42 -0000 >@@ -95,4 +95,9 @@ > // lazily set after annotation type was resolved > this.binding = binding; > } >+ >+void setValue(Object value) { >+ // can be modified after the initialization if holding an unresolved ref >+ this.value = value; >+} > } >#P org.eclipse.jdt.core.tests.model >Index: workspace/Converter15/.classpath >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Converter15/.classpath,v >retrieving revision 1.3 >diff -u -r1.3 .classpath >--- workspace/Converter15/.classpath 28 Oct 2004 21:30:36 -0000 1.3 >+++ workspace/Converter15/.classpath 11 Oct 2006 13:09:51 -0000 >@@ -4,4 +4,5 @@ > <classpathentry kind="var" path="CONVERTER_JCL15_LIB" sourcepath="CONVERTER_JCL15_SRC" rootpath="CONVERTER_JCL_SRCROOT"/> > <classpathentry kind="output" path="bin"/> > <classpathentry kind="lib" sourcepath="src" path="bins"/> >+ <classpathentry kind="lib" path="bins/binaries.jar"/> > </classpath> >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v >retrieving revision 1.200.2.1 >diff -u -r1.200.2.1 ASTConverter15Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 2 Jul 2006 10:06:41 -0000 1.200.2.1 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 11 Oct 2006 13:09:51 -0000 >@@ -12,6 +12,7 @@ > package org.eclipse.jdt.core.tests.dom; > > import java.io.IOException; >+import java.util.ArrayList; > import java.util.HashMap; > import java.util.List; > import java.util.Map; >@@ -6962,4 +6963,75 @@ > CompilationUnit unit = (CompilationUnit) node; > assertProblemsSize(unit, 0); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=155115 >+public void test0227() throws JavaModelException { >+ this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); >+ String contents = >+ "import anno.Anno;\n" + >+ "import binary.B;\n" + >+ "import intf.IFoo;\n" + >+ "\n" + >+ "public class X extends B {\n" + >+ " @Anno(clz=IFoo.IBar.class)\n" + >+ // the annotation we chase up is not this one, but the one >+ // carried by B#f >+ " public void f() {}\n" + >+ " IFoo.IBar m;\n" + >+ "}"; >+ class TestASTRequestor extends ASTRequestor { >+ public ArrayList asts = new ArrayList(); >+ public void acceptAST(ICompilationUnit source, CompilationUnit compilationUnit) { >+ this.asts.add(compilationUnit); >+ } >+ public void acceptBinding(String bindingKey, IBinding binding) { >+ } >+ } >+ this.workingCopy.getBuffer().setContents(contents); >+ this.workingCopy.save(null, true); >+ TestASTRequestor requestor = new TestASTRequestor(); >+ resolveASTs(new ICompilationUnit[] { this.workingCopy } , new String[0], requestor, this.getJavaProject("Converter15"), null); >+ ArrayList asts = requestor.asts; >+ assertEquals("Wrong size", 1, asts.size()); >+ CompilationUnit compilationUnit = (CompilationUnit) asts.get(0); >+ assertNotNull("No compilation unit", compilationUnit); >+ List types = compilationUnit.types(); >+ assertEquals("Wrong size", 1, types.size()); >+ AbstractTypeDeclaration abstractTypeDeclaration = (AbstractTypeDeclaration) types.get(0); >+ assertEquals("Wrong type", ASTNode.TYPE_DECLARATION, abstractTypeDeclaration.getNodeType()); >+ TypeDeclaration declaration = (TypeDeclaration) abstractTypeDeclaration; >+ Type superclass = declaration.getSuperclassType(); >+ assertNotNull("No superclass", superclass); >+ ITypeBinding typeBinding = superclass.resolveBinding(); >+ assertNotNull("No binding", typeBinding); >+ IMethodBinding[] methods = typeBinding.getDeclaredMethods(); >+ assertNotNull("No methods", methods); >+ assertEquals("Wrong size", 2, methods.length); >+ IMethodBinding methodBinding = null; >+ for(int i = 0; i < 2; i++) { >+ methodBinding = methods[i]; >+ if (methodBinding.getName().equals("f")) { >+ break; >+ } >+ } >+ assertEquals("Wrong name", "f", methodBinding.getName()); >+ IAnnotationBinding[] annotationBindings = methodBinding.getAnnotations(); >+ assertNotNull("No annotations", annotationBindings); >+ assertEquals("Wrong size", 1, annotationBindings.length); >+ IAnnotationBinding annotationBinding = annotationBindings[0]; >+ IMemberValuePairBinding[] pairs = annotationBinding.getAllMemberValuePairs(); >+ assertNotNull("no pairs", pairs); >+ assertEquals("Wrong size", 1, pairs.length); >+ IMemberValuePairBinding memberValuePairBinding = pairs[0]; >+ assertEquals("Wrong kind", IBinding.MEMBER_VALUE_PAIR, memberValuePairBinding.getKind()); >+ Object value = memberValuePairBinding.getValue(); >+ assertNotNull("No value", value); >+ assertTrue("Not a type binding", value instanceof ITypeBinding); >+ assertEquals("Wrong qualified name", "intf.IFoo.IBar", >+ ((ITypeBinding) value).getQualifiedName()); >+ IVariableBinding[] fields = >+ declaration.resolveBinding().getDeclaredFields(); >+ assertTrue("Bad field definition", fields != null && fields.length == 1); >+ assertEquals("Type binding mismatch", value, fields[0].getType()); >+} > } >\ No newline at end of file >Index: workspace/Converter15/bins/binaries.jar >=================================================================== >RCS file: workspace/Converter15/bins/binaries.jar >diff -N workspace/Converter15/bins/binaries.jar >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Converter15/bins/binaries.jar 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+PK½j5META-INF/MANIFEST.MFþÊóMÌËLK-.Ñ >+K-*ÎÌϳR0Ô3àåâåPK²îPKÔh5anno/Anno.class ??KAÅßD5ñ_4(Ak+Ñ ÄÈyÚXm!lØìIn/? À%ÎÆâ?}ìþÞf¾>¿\¢§Ð ´µsyt-Ea?Ð?ê ¬vh4ræZãê5à^{»éOÖ2ûAè??*ôÆꢸ"tórñ?±,ýë"@¤tÞÌøÕfl¹Ê+'Ú {vAIns¡m)ýЧÜl)¼<¦ÃpToIõ|Â^ÈÓúÿØòL2Óå;ÔÆéýè¶O?ùå4e$;TØÕ@{U;ØûPÔ0Ûì¢ä±ý_PK+?SYøPKºj5binary/A.class]OMKÃ@}¤ILªU~¡gEB¡TrßÄnIw!Ýú¯< üþ(q?fÞÌ·ovß?^ß±À! Ò¢~LÒa8"©¾K.¹,-Á?QZÙS»·¼ss+#¸Xé£0ÈÍ¢?õ?(*Ie¦U.jÕöߤgïÕe?û 4#l_5Úª ÌÕR±0ÕÚXaÑ,3ÁmÒr¬vËê_Èëì,NÙ?ѵiêRNT»ÇO?Ú?`|íq¸âr¸K±wðð¹Gýôsî W kÌ;ps7äX/1êÜ;ǧð?ý:mtªÍOPKdµEPK¸j5binary/B.class]NMKÃ@¤ILªU~Á³"4B¡<¨ä¾[\Iw!Ýõ_y<øú£ÄøûæͼÙy»z}p?!,õ2Ix¿lLðÏVöàæïÒÜÉ.ÖúèÁ'2¥åU3/d}+JF)EZµüKôì½Z¢ì{Ï?fÝëF[5¹Z(6µ6VXe4ãL0MZ?ÝnY=¼ÎÎéÄýi*jD7¦©K9Qí?=y?{àh?ÃÿkÀ,a$ÆÞÑÂçnqõ;ÑG̵ÿi`\g$l°î`À}ÌlÈw³Ä¨K;î|ÿ' è'i«smPKówU{PKåh5intf/IFoo$IBar.class;õo×>Cnv&F¾Ì¼4}O·ü|O§Ä"vF?¬Ä²Dýļt}ÿ¤¬ÔäF®àüÒ¢äT·ÌTFN?r=?"Fϼ¼Ô"çÄââÔbvN ,ÜDF?lÌÀÄÀ >+&ÙØ?4H??PKfû?PKåh5intf/IFoo.class;õo×>Cnv&FÎ̼4}O·ü|vF?¬Ä²Dýļt}ÿ¤¬ÔäF®àüÒ¢äT·ÌT r?J=?"Fϼ¼Ô"çÄââÔbvNF>¸a*NE, ???XÁ$;?æÊp1'PK¯¼ÕPK½j5²îMETA-INF/MANIFEST.MFþÊPKÔh5+?SYøaanno/Anno.classPKºj5dµEbinary/A.classPK¸j5ówU{äbinary/B.classPKåh5fû?'intf/IFoo$IBar.classPKåh5¯¼Õêintf/IFoo.classPKz§
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 155115
:
48644
|
48645
|
48646
|
49405
| 51753