### 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 @@ + 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ÅßD“5ñ_4•ˆ(Ak+Ñ…ÄÈyÚXmŽ!lØìIn/?š…À%ÎÆâš‹?}ìþÞf¾>¿\¢§Ð ´µsyt-Ea?Ð?ê…Ž¬v“h4žræ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~€¡gEˆB¡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µEƒPK¸j5binary/B.class]NMKÃ@œ—¤ILª­U~€Á³"4B¡<¨ä¾‰[\Iw!Ýõ_y<øú£Ä—ø‰ ûæͼÙy»z}pŠ?!,”õ2Ix¿lLðÏ•Vö‚àæïÒÜÉ.ÖúèÁ' 2¥åU3/d}+ŠJF™)E•‹Zµü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*žN‰EŒ , Š?‘?‘?™˜XÁ$;?æÊp1'PK¯¼Õ€˜PK½j5²îMETA-INF/MANIFEST.MFþÊPKÔh5+?SYø’aanno/Anno.classPKºj5dµEƒ–binary/A.classPK¸j5ówU{äbinary/B.classPKåh5fû˜?˜'intf/IFoo$IBar.classPKåh5¯¼Õ€˜êintf/IFoo.classPKz§