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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedAnnotationBinding.java (-8 / +26 lines)
Lines 12-17 Link Here
12
12
13
public class UnresolvedAnnotationBinding extends AnnotationBinding {
13
public class UnresolvedAnnotationBinding extends AnnotationBinding {
14
	private LookupEnvironment env;
14
	private LookupEnvironment env;
15
	private boolean typeUnresolved = true;
15
16
16
UnresolvedAnnotationBinding(ReferenceBinding type, ElementValuePair[] pairs, LookupEnvironment env) {
17
UnresolvedAnnotationBinding(ReferenceBinding type, ElementValuePair[] pairs, LookupEnvironment env) {
17
	super(type, pairs);
18
	super(type, pairs);
Lines 19-38 Link Here
19
}
20
}
20
21
21
public ReferenceBinding getAnnotationType() {
22
public ReferenceBinding getAnnotationType() {
22
	// the type is resolved when requested
23
	if (this.typeUnresolved) { // the type is resolved when requested
23
	if (this.env != null) {
24
		// annotation type are never parameterized
25
		this.type = BinaryTypeBinding.resolveType(this.type, this.env, false);
24
		this.type = BinaryTypeBinding.resolveType(this.type, this.env, false);
26
		this.env = null;
25
			// annotation type are never parameterized
27
		setMethodBindings();
26
		this.typeUnresolved = false;
28
	}
27
	}
29
	return this.type;
28
	return this.type;
30
}
29
}
31
30
32
public ElementValuePair[] getElementValuePairs() {
31
public ElementValuePair[] getElementValuePairs() {
33
	if (this.env != null)
32
	if (this.env != null) {
34
		getAnnotationType(); // resolve the annotation type & method bindings of each pair
33
		if (this.typeUnresolved) {
35
34
			getAnnotationType(); // resolve the annotation type
35
		}
36
		// resolve method binding and value type (if unresolved) for each pair
37
		for (int i = this.pairs.length; --i >= 0;) {
38
			ElementValuePair pair = this.pairs[i];
39
			MethodBinding[] methods = this.type.getMethods(pair.getName());
40
			// there should be exactly one since the type is an annotation type.
41
			if (methods != null && methods.length == 1) {
42
				pair.setMethodBinding(methods[0]);
43
			} // else silently leave a null there
44
			Object value = pair.getValue();
45
			if (value instanceof UnresolvedReferenceBinding) {
46
				pair.setValue(((UnresolvedReferenceBinding) value).
47
						resolve(this.env, false));
48
							// no parameterized types in annotation values
49
			} // do nothing for UnresolvedAnnotationBinding-s, since their 
50
			  // content is only accessed through get* methods
51
		}
52
		this.env = null;
53
	}
36
	return this.pairs;
54
	return this.pairs;
37
}
55
}
38
}
56
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java (+5 lines)
Lines 95-98 Link Here
95
	// lazily set after annotation type was resolved
95
	// lazily set after annotation type was resolved
96
	this.binding = binding;
96
	this.binding = binding;
97
}
97
}
98
99
void setValue(Object value) {
100
	// can be modified after the initialization if holding an unresolved ref
101
	this.value = value;
102
}
98
}
103
}
(-)workspace/Converter15/.classpath (+1 lines)
Lines 4-7 Link Here
4
    <classpathentry kind="var" path="CONVERTER_JCL15_LIB" sourcepath="CONVERTER_JCL15_SRC" rootpath="CONVERTER_JCL_SRCROOT"/>    
4
    <classpathentry kind="var" path="CONVERTER_JCL15_LIB" sourcepath="CONVERTER_JCL15_SRC" rootpath="CONVERTER_JCL_SRCROOT"/>    
5
    <classpathentry kind="output" path="bin"/>
5
    <classpathentry kind="output" path="bin"/>
6
    <classpathentry kind="lib" sourcepath="src" path="bins"/>
6
    <classpathentry kind="lib" sourcepath="src" path="bins"/>
7
	<classpathentry kind="lib" path="bins/binaries.jar"/>
7
</classpath>
8
</classpath>
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (+72 lines)
Lines 12-17 Link Here
12
package org.eclipse.jdt.core.tests.dom;
12
package org.eclipse.jdt.core.tests.dom;
13
13
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.HashMap;
16
import java.util.List;
17
import java.util.List;
17
import java.util.Map;
18
import java.util.Map;
Lines 6962-6965 Link Here
6962
		CompilationUnit unit = (CompilationUnit) node;
6963
		CompilationUnit unit = (CompilationUnit) node;
6963
		assertProblemsSize(unit, 0);
6964
		assertProblemsSize(unit, 0);
6964
	}
6965
	}
6966
6967
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=155115
6968
public void test0227() throws JavaModelException {
6969
	this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
6970
	String contents =
6971
		"import anno.Anno;\n" + 
6972
		"import binary.B;\n" + 
6973
		"import intf.IFoo;\n" + 
6974
		"\n" + 
6975
		"public class X extends B {\n" + 
6976
		"	@Anno(clz=IFoo.IBar.class)\n" + 
6977
			// the annotation we chase up is not this one, but the one
6978
			// carried by B#f
6979
		"	public void f() {}\n" +
6980
		"   IFoo.IBar m;\n" + 
6981
		"}";
6982
	class TestASTRequestor extends ASTRequestor {
6983
		public ArrayList asts = new ArrayList();
6984
		public void acceptAST(ICompilationUnit source, CompilationUnit compilationUnit) {
6985
			this.asts.add(compilationUnit);
6986
		}
6987
		public void acceptBinding(String bindingKey, IBinding binding) {
6988
		}
6989
	}
6990
	this.workingCopy.getBuffer().setContents(contents);
6991
	this.workingCopy.save(null, true);
6992
	TestASTRequestor requestor = new TestASTRequestor();
6993
	resolveASTs(new ICompilationUnit[] { this.workingCopy } , new String[0], requestor, this.getJavaProject("Converter15"), null);
6994
	ArrayList asts = requestor.asts;
6995
	assertEquals("Wrong size", 1, asts.size());
6996
	CompilationUnit compilationUnit = (CompilationUnit) asts.get(0);
6997
	assertNotNull("No compilation unit", compilationUnit);
6998
	List types = compilationUnit.types();
6999
	assertEquals("Wrong size", 1, types.size());
7000
	AbstractTypeDeclaration abstractTypeDeclaration = (AbstractTypeDeclaration) types.get(0);
7001
	assertEquals("Wrong type", ASTNode.TYPE_DECLARATION, abstractTypeDeclaration.getNodeType());
7002
	TypeDeclaration declaration = (TypeDeclaration) abstractTypeDeclaration;
7003
	Type superclass = declaration.getSuperclassType();
7004
	assertNotNull("No superclass", superclass);
7005
	ITypeBinding typeBinding = superclass.resolveBinding();
7006
	assertNotNull("No binding", typeBinding);
7007
	IMethodBinding[] methods = typeBinding.getDeclaredMethods();
7008
	assertNotNull("No methods", methods);
7009
	assertEquals("Wrong size", 2, methods.length);
7010
	IMethodBinding methodBinding = null;
7011
	for(int i = 0; i < 2; i++) {
7012
		methodBinding = methods[i];
7013
		if (methodBinding.getName().equals("f")) {
7014
			break;
7015
		}
7016
	}
7017
	assertEquals("Wrong name", "f", methodBinding.getName());
7018
	IAnnotationBinding[] annotationBindings = methodBinding.getAnnotations();
7019
	assertNotNull("No annotations", annotationBindings);
7020
	assertEquals("Wrong size", 1, annotationBindings.length);
7021
	IAnnotationBinding annotationBinding = annotationBindings[0];
7022
	IMemberValuePairBinding[] pairs = annotationBinding.getAllMemberValuePairs();
7023
	assertNotNull("no pairs", pairs);
7024
	assertEquals("Wrong size", 1, pairs.length);
7025
	IMemberValuePairBinding memberValuePairBinding = pairs[0];
7026
	assertEquals("Wrong kind", IBinding.MEMBER_VALUE_PAIR, memberValuePairBinding.getKind());
7027
	Object value = memberValuePairBinding.getValue();
7028
	assertNotNull("No value", value);
7029
	assertTrue("Not a type binding", value instanceof ITypeBinding);
7030
	assertEquals("Wrong qualified name", "intf.IFoo.IBar", 
7031
			((ITypeBinding) value).getQualifiedName());		
7032
	IVariableBinding[] fields = 
7033
		declaration.resolveBinding().getDeclaredFields();
7034
	assertTrue("Bad field definition", fields != null && fields.length == 1);
7035
	assertEquals("Type binding mismatch", value, fields[0].getType());
7036
}
6965
}
7037
}
(-)workspace/Converter15/bins/binaries.jar (+3 lines)
Added Link Here
1
PK½j5META-INF/MANIFEST.MFþÊóMÌËLK-.Ñ
2
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ŒŒÌÀÄÀ
3
&ÙØ?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§

Return to bug 155115