### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core.tests.model
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.280
diff -u -r1.280 ASTConverter15Test.java
--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 29 Nov 2008 22:35:14 -0000 1.280
+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 21 Jan 2009 11:36:24 -0000
@@ -61,7 +61,126 @@
this.workingCopy = null;
}
}
+
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=234609 BindingKey#toSignature() fails with key from createWilcardTypeBindingKey(..)
+ public void test234609() throws JavaModelException {
+
+ String newContents = "package p;\n" +
+ "import java.util.HashMap;\n" +
+ "public class X {\n" +
+ " /*start*/HashMap extends Integer,? super String>/*end*/ s;" +
+ "}";
+ this.workingCopy = getWorkingCopy("/Converter15/src/p/X.java", true/*resolve*/);
+
+ Type node = (Type) buildAST(
+ newContents,
+ this.workingCopy);
+
+ ITypeBinding bindingFromAST = node.resolveBinding();
+ String recoveredBindingKey = bindingFromAST.getKey();
+
+ String genericTypeKey = BindingKey.createTypeBindingKey("java.util.HashMap");
+ String [] wildcardKeys = new String [] { BindingKey.createWildcardTypeBindingKey(genericTypeKey, Signature.C_EXTENDS, BindingKey.createTypeBindingKey("java.lang.Integer"), 0),
+ BindingKey.createWildcardTypeBindingKey(genericTypeKey, Signature.C_SUPER, BindingKey.createTypeBindingKey("java.lang.String"), 1)
+ };
+
+ String composedBindingKey = BindingKey.createParameterizedTypeBindingKey(genericTypeKey, wildcardKeys);
+
+ if (!composedBindingKey.equals(recoveredBindingKey))
+ fail("Composed binding key differs from Recovered binding key");
+
+
+ this.workingCopy.discardWorkingCopy();
+ this.workingCopy = null;
+
+ ITypeBinding [] bindingFromKey = createTypeBindings(
+ new String[] {
+ "/Converter15/src/p/X.java",
+ newContents
+ },
+ new String[] {
+ composedBindingKey
+ },
+ getJavaProject("Converter15")
+ );
+
+ if (bindingFromKey.length != 1)
+ fail("Problem in going from key to binding\n");
+ if (!composedBindingKey.equals(bindingFromKey[0].getKey()))
+ fail ("Binding key mismatch");
+ String signature = new BindingKey(composedBindingKey).toSignature();
+ if (!signature.equals("Ljava.util.HashMap<+Ljava.lang.Integer;-Ljava.lang.String;>;"))
+ fail("Bad signature");
+
+ assertTrue("Equals", bindingFromKey[0].isEqualTo(bindingFromAST));
+
+ // check existence of getGenericType() API.
+ ITypeBinding gType = bindingFromAST.getTypeArguments()[0].getGenericTypeOfWildcardType();
+ if (gType == null)
+ fail("Missing generic type");
+ if (!gType.getKey().equals("Ljava/util/HashMap;"))
+ fail("getKey() API is broken");
+
+ // test for getRank API.
+ if (bindingFromAST.getTypeArguments()[0].getRank() != 0)
+ fail ("Wrong rank");
+
+ if (bindingFromAST.getTypeArguments()[1].getRank() != 1)
+ fail ("Wrong rank");
+ }
+
+ // Similar test as above - variation in wildcard type being unbounded.
+ public void test234609b() throws JavaModelException {
+
+ String newContents = "package p;\n" +
+ "import java.util.ArrayList;\n" +
+ "public class X {\n" +
+ " /*start*/ArrayList>/*end*/ s;" +
+ "}";
+
+ this.workingCopy = getWorkingCopy("/Converter15/src/p/X.java", true/*resolve*/);
+
+ Type node = (Type) buildAST(
+ newContents,
+ this.workingCopy);
+
+ ITypeBinding bindingFromAST = node.resolveBinding();
+ String recoveredBindingKey = bindingFromAST.getKey();
+
+ String genericTypeKey = BindingKey.createTypeBindingKey("java.util.ArrayList");
+ String [] wildcardKeys = new String [] { BindingKey.createWildcardTypeBindingKey(genericTypeKey, Signature.C_STAR, null, 0) };
+
+ String composedBindingKey = BindingKey.createParameterizedTypeBindingKey(genericTypeKey, wildcardKeys);
+
+ if (!composedBindingKey.equals(recoveredBindingKey))
+ fail("Composed binding key differs from Recovered binding key");
+
+
+ this.workingCopy.discardWorkingCopy();
+ this.workingCopy = null;
+
+ ITypeBinding [] bindingFromKey = createTypeBindings(
+ new String[] {
+ "/Converter15/src/p/X.java",
+ newContents
+ },
+ new String[] {
+ composedBindingKey
+ },
+ getJavaProject("Converter15")
+ );
+
+ if (bindingFromKey.length != 1)
+ fail("Problem in going from key to binding\n");
+ if (!composedBindingKey.equals(bindingFromKey[0].getKey()))
+ fail ("Binding key mismatch");
+ String signature = new BindingKey(composedBindingKey).toSignature();
+ if (!signature.equals("Ljava.util.ArrayList<*>;"))
+ fail("Bad signature");
+ assertTrue("Equals", bindingFromKey[0].isEqualTo(bindingFromAST));
+ }
+
public void test0001() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0001", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2710,7 +2829,7 @@
this.workingCopy);
IBinding binding = ((MethodInvocation) node).resolveMethodBinding();
assertBindingKeyEquals(
- "Lp/X;.foo()V",
+ "Lp/X;.foo()V",
binding.getKey());
}
@@ -3531,7 +3650,7 @@
this.workingCopy);
ITypeBinding binding = type.resolveBinding().getTypeDeclaration();
assertBindingEquals(
- "LX;+Ljava/lang/String;",
+ "LX;{0}+Ljava/lang/String;",
binding);
}
@@ -3731,7 +3850,7 @@
this.workingCopy);
ITypeBinding binding = type.resolveBinding();
assertBindingEquals(
- "Ljava/lang/Class;",
+ "Ljava/lang/Class;",
binding);
}
@@ -10175,7 +10294,7 @@
this.workingCopy);
IBinding binding = ((MethodInvocation) node).resolveTypeBinding();
assertBindingKeyEquals(
- "Lpack1/E;>;",
+ "Lpack1/E;>;",
binding.getKey());
}
/*
Index: src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java,v
retrieving revision 1.82
diff -u -r1.82 BatchASTCreationTests.java
--- src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 8 Jan 2009 20:54:33 -0000 1.82
+++ src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 21 Jan 2009 11:36:27 -0000
@@ -929,7 +929,7 @@
" }\n" +
"}",
},
- "Lp1/X;.foo()V");
+ "Lp1/X;.foo()V");
}
/*
@@ -948,7 +948,7 @@
" }\n" +
"}",
},
- "Lp1/X;.foo()V");
+ "Lp1/X;.foo()V");
}
/*
@@ -967,7 +967,7 @@
" }\n" +
"}",
},
- "Lp1/X;.foo()V");
+ "Lp1/X;.foo()V");
}
/*
@@ -986,7 +986,7 @@
" }\n" +
"}",
},
- "Lp1/X;.foo()V");
+ "Lp1/X;.foo()V");
}
/*
@@ -1036,7 +1036,7 @@
" X super T> field;\n" +
"}",
},
- "Lp1/X;");
+ "Lp1/X;");
}
/*
@@ -1052,7 +1052,7 @@
" Class extends E> field;\n" +
"}",
},
- "Ljava/lang/Class;");
+ "Ljava/lang/Class;");
}
/*
@@ -1073,12 +1073,12 @@
},
new String[] {
"Lp1/X;",
- "Lp1/Y;"
+ "Lp1/Y;"
}
);
assertBindingsEqual(
"Lp1/X;\n" +
- "Lp1/Y;",
+ "Lp1/Y;",
bindings);
}
@@ -1133,9 +1133,9 @@
public void test050() throws CoreException {
ITypeBinding[] bindings = createTypeBindings(
new String[] {},
- new String[] {"Ljava/lang/Class;+[Ljava/lang/Object;>;"});
+ new String[] {"Ljava/lang/Class;{0}+[Ljava/lang/Object;>;"});
assertBindingsEqual(
- "Ljava/lang/Class;",
+ "Ljava/lang/Class;",
bindings);
}
@@ -1311,7 +1311,7 @@
" }\n" +
"}",
},
- "Lp1/X;&!Lp1/X;*77;"
+ "Lp1/X;&!Lp1/X;{0}*77;"
);
}
@@ -1338,7 +1338,7 @@
" }\n" +
"}"
},
- "Lxy/Cap;&!Ljava/util/Vector;*82;"
+ "Lxy/Cap;&!Ljava/util/Vector;{0}*82;"
);
}
@@ -1404,7 +1404,7 @@
"class W extends Z {\n" +
"}",
},
- "Lp1/X;.foo;>(Lp1/Z;)V%;>;>"
+ "Lp1/X;.foo;>(Lp1/Z;)V%;>;>"
);
}
@@ -1461,7 +1461,7 @@
},
new String[] {
"Lp1/X;",
- "Lp1/X;&Lp1/Y;",
+ "Lp1/X;&Lp1/Y;",
}
);
}
Index: src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java,v
retrieving revision 1.40
diff -u -r1.40 BindingKeyTests.java
--- src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java 27 Jun 2008 16:02:38 -0000 1.40
+++ src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java 21 Jan 2009 11:36:28 -0000
@@ -261,34 +261,54 @@
key);
}
+ /**
+ * @deprecated
+ */
+ private String getWildcardBindingKey(String typeKey, char kind) {
+ return BindingKey.createWilcardTypeBindingKey(typeKey, kind);
+ }
+
/*
* Create a wildcard type binding key
*/
public void test022() {
- String key = BindingKey.createWilcardTypeBindingKey(null, Signature.C_STAR);
+ String key = getWildcardBindingKey(null, Signature.C_STAR);
assertBindingKeyEquals(
"*",
key);
+ assertBindingKeyEquals(BindingKey.createWildcardTypeBindingKey(
+ BindingKey.createTypeBindingKey("java.util.ArrayList"), Signature.C_STAR, null, 0),
+ "Ljava/util/ArrayList;{0}*");
}
/*
* Create a wildcard type binding key
*/
public void test023() {
- String key = BindingKey.createWilcardTypeBindingKey("Ljava/util/List;", Signature.C_SUPER);
+ String key = getWildcardBindingKey("Ljava/util/List;", Signature.C_SUPER);
assertBindingKeyEquals(
"-Ljava/util/List;",
key);
+ assertBindingKeyEquals(BindingKey.createWildcardTypeBindingKey(
+ BindingKey.createTypeBindingKey("java.util.ArrayList"), Signature.C_SUPER,
+ BindingKey.createTypeBindingKey("java.lang.String"), 0),
+ "Ljava/util/ArrayList;{0}-Ljava/lang/String;"
+ );
}
/*
* Create a wildcard type binding key
*/
public void test024() {
- String key = BindingKey.createWilcardTypeBindingKey("Ljava/util/ArrayList;", Signature.C_EXTENDS);
+ String key = getWildcardBindingKey("Ljava/util/ArrayList;", Signature.C_EXTENDS);
assertBindingKeyEquals(
"+Ljava/util/ArrayList;",
key);
+ assertBindingKeyEquals(BindingKey.createWildcardTypeBindingKey(
+ BindingKey.createTypeBindingKey("java.util.ArrayList"), Signature.C_EXTENDS,
+ BindingKey.createTypeBindingKey("java.lang.String"), 0),
+ "Ljava/util/ArrayList;{0}+Ljava/lang/String;"
+ );
}
/*
@@ -327,7 +347,7 @@
public void test028() {
assertBindingKeySignatureEquals(
"*",
- "Lp1/X;*"
+ "Lp1/X;{0}*"
);
}
@@ -337,7 +357,7 @@
public void test029() {
assertBindingKeySignatureEquals(
"-Ljava.util.List;",
- "Lp1/X;-Ljava/util/List;"
+ "Lp1/X;{0}-Ljava/util/List"
);
}
@@ -347,7 +367,7 @@
public void test030() {
assertBindingKeySignatureEquals(
"+Ljava.util.ArrayList;",
- "Lp1/X;+Ljava/util/ArrayList;"
+ "Lp1/X;{0}+Ljava/util/ArrayList;"
);
}
@@ -357,7 +377,7 @@
public void test031() {
assertBindingKeySignatureEquals(
"!*",
- "Ljava/util/List;&!Lp1/X;*123;"
+ "Ljava/util/List;&!Lp1/X;{0}*123;"
);
}
@@ -367,7 +387,7 @@
public void test032() {
assertBindingKeySignatureEquals(
"!-Ljava.util.List;",
- "Ljava/util/List;&!Lp1/X;-Ljava/util/List;123;"
+ "Ljava/util/List;&!Lp1/X;{0}-Ljava/util/List;123;"
);
}
@@ -377,7 +397,7 @@
public void test033() {
assertBindingKeySignatureEquals(
"!+Ljava.util.ArrayList;",
- "Ljava/util/List;&!Lp1/X;+Ljava/util/ArrayList<>;123;"
+ "Ljava/util/List;&!Lp1/X;{0}+Ljava/util/ArrayList<>;123;"
);
}
@@ -598,7 +618,7 @@
public void test054() {
assertBindingKeySignatureEquals(
"!*",
- "LX;&LX~Box;.value)!LX~Box;*232;"
+ "LX;&LX~Box;.value)!LX~Box;{0}*232;"
);
}
}
Index: src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java,v
retrieving revision 1.109
diff -u -r1.109 CompletionTests_1_5.java
--- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 9 Sep 2008 12:43:37 -0000 1.109
+++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 21 Jan 2009 11:36:50 -0000
@@ -6082,7 +6082,7 @@
assertResults(
"expectedTypesSignatures={Ltest0191.ZZClass1<+TU;>;}\n" +
- "expectedTypesKeys={Ltest0191/Test~ZZClass1;}",
+ "expectedTypesKeys={Ltest0191/Test~ZZClass1;}",
result.context);
assertResults(
Index: src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java,v
retrieving revision 1.64
diff -u -r1.64 ResolveTests_1_5.java
--- src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 23 Jul 2008 09:48:37 -0000 1.64
+++ src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 21 Jan 2009 11:36:54 -0000
@@ -2109,7 +2109,7 @@
assertElementsEqual(
"Unexpected elements",
- "Y {key=Ltest0095/X~Y;>;} [in [Working copy] X.java [in test0095 [in src2 [in Resolve]]]]",
+ "Y {key=Ltest0095/X~Y;>;} [in [Working copy] X.java [in test0095 [in src2 [in Resolve]]]]",
elements,
true/*show key*/
);
#P org.eclipse.jdt.core
Index: model/org/eclipse/jdt/core/BindingKey.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BindingKey.java,v
retrieving revision 1.22
diff -u -r1.22 BindingKey.java
--- model/org/eclipse/jdt/core/BindingKey.java 27 Jun 2008 16:04:01 -0000 1.22
+++ model/org/eclipse/jdt/core/BindingKey.java 21 Jan 2009 11:37:08 -0000
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.core;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.core.util.KeyKind;
import org.eclipse.jdt.internal.core.util.KeyToSignature;
@@ -169,9 +170,12 @@
* @param typeKey the binding key of the given type
* @param kind one of {@link Signature#C_STAR}, {@link Signature#C_SUPER}, or {@link Signature#C_EXTENDS}
* @return a new wildcard type binding key
+ * @deprecated This method is missing crucial information necessary for proper wildcard binding key creation.
+ * @see org.eclipse.jdt.core.BindingKey#createWildcardTypeBindingKey(String, char, String, int)
*/
public static String createWilcardTypeBindingKey(String typeKey, char kind) {
- // Note this implementation is heavily dependent on WildcardBinding#computeUniqueKey()
+ // Note this implementation is supposed to closely follow the behavior in WildcardBinding#computeUniqueKey()
+ // but it doesn't and hence the deprecation. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=234609
switch (kind) {
case Signature.C_STAR:
return "*"; //$NON-NLS-1$
@@ -184,6 +188,50 @@
}
/**
+ * Creates a new wildcard type binding key from the given generic type binding key, the given wildcard
+ * kind (one of {@link Signature#C_STAR}, {@link Signature#C_SUPER}, or {@link Signature#C_EXTENDS}
+ * the given bound type binding key and the given rank. If the wildcard kind is {@link Signature#C_STAR},
+ * the given bound type binding key is ignored.
+ *
+ * For example:
+ *
+ *
+ * createWildcardTypeBindingKey("Ljava/util/ArrayList;", Signature.C_STAR, null, 0) -> "Ljava/util/ArrayList;{0}*"
+ * createWildcardTypeBindingKey("Ljava/util/ArrayList;", Signature.C_SUPER, "Ljava/lang/String;", 0) -> "Ljava/util/ArrayList;{0}-Ljava/lang/String;"
+ * createWildcardTypeBindingKey("Ljava/util/HashMap;", Signature.C_EXTENDS, "Ljava/lang/String;", 1) ->
+ * "Ljava/util/HashMap;{1}+Ljava/lang/String;"
+ *
+ *
+ *
+ *
+ * @param genericTypeKey the binding key of the generic type
+ * @param boundKind one of {@link Signature#C_STAR}, {@link Signature#C_SUPER}, or {@link Signature#C_EXTENDS}
+ * @param boundTypeKey the binding key of the bounding type.
+ * @param rank the relative position of this wild card type in the parameterization of the generic type.
+ * @return a new wildcard type binding key
+ * @since 3.5
+ */
+
+ public static String createWildcardTypeBindingKey(String genericTypeKey, char boundKind, String boundTypeKey, int rank) {
+ // Note this implementation is heavily dependent on WildcardBinding#computeUniqueKey()
+ String wildCardKey;
+ switch (boundKind) {
+ case Signature.C_STAR:
+ wildCardKey = new String(TypeConstants.WILDCARD_STAR);
+ break;
+ case Signature.C_SUPER:
+ wildCardKey = new String(TypeConstants.WILDCARD_MINUS) + boundTypeKey;
+ break;
+ case Signature.C_EXTENDS:
+ wildCardKey = new String(TypeConstants.WILDCARD_PLUS) + boundTypeKey;
+ break;
+ default:
+ return null;
+ }
+ return genericTypeKey + '{' + rank + '}' + wildCardKey;
+ }
+
+ /**
* Returns the thrown exception signatures of the element represented by this binding key.
* If this binding key does not represent a method or does not throw any exception,
* returns an empty array.
Index: dom/org/eclipse/jdt/core/dom/TypeBinding.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java,v
retrieving revision 1.143
diff -u -r1.143 TypeBinding.java
--- dom/org/eclipse/jdt/core/dom/TypeBinding.java 6 Oct 2008 13:23:51 -0000 1.143
+++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 21 Jan 2009 11:37:08 -0000
@@ -163,7 +163,37 @@
}
return null;
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ITypeBinding#getGenericTypeOfWildcardType()
+ */
+ public ITypeBinding getGenericTypeOfWildcardType() {
+ switch (this.binding.kind()) {
+ case Binding.WILDCARD_TYPE :
+ case Binding.INTERSECTION_TYPE :
+ WildcardBinding wildcardBinding = (WildcardBinding) this.binding;
+ if (wildcardBinding.genericType != null) {
+ return this.resolver.getTypeBinding(wildcardBinding.genericType);
+ }
+ break;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ITypeBinding#getRank()
+ */
+ public int getRank() {
+ switch (this.binding.kind()) {
+ case Binding.WILDCARD_TYPE :
+ case Binding.INTERSECTION_TYPE :
+ WildcardBinding wildcardBinding = (WildcardBinding) this.binding;
+ return wildcardBinding.rank;
+ default:
+ return -1;
+ }
+ }
+
/*
* @see ITypeBinding#getComponentType()
*/
Index: dom/org/eclipse/jdt/core/dom/ITypeBinding.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java,v
retrieving revision 1.72
diff -u -r1.72 ITypeBinding.java
--- dom/org/eclipse/jdt/core/dom/ITypeBinding.java 27 Jun 2008 16:03:46 -0000 1.72
+++ dom/org/eclipse/jdt/core/dom/ITypeBinding.java 21 Jan 2009 11:37:05 -0000
@@ -89,8 +89,29 @@
* @since 3.1
*/
public ITypeBinding getBound();
+
+ /**
+ * Returns the generic type associated with this wildcard type, if it has one.
+ * Returns null
if this is not a wildcard type.
+ *
+ * @return the generic type associated with this wildcard type, or null
if none
+ * @see #isWildcardType()
+ * @since 3.5
+ */
+ public ITypeBinding getGenericTypeOfWildcardType();
/**
+ * Returns the rank associated with this wildcard type. The rank of this wild card type is the relative
+ * position of the wild card type in the parameterization of the associated generic type.
+ * Returns -1
if this is not a wildcard type.
+ *
+ * @return the rank associated with this wildcard type, or -1
if none
+ * @see #isWildcardType()
+ * @since 3.5
+ */
+ public int getRank();
+
+ /**
* Returns the binding representing the component type of this array type,
* or null
if this is not an array type binding. The component
* type of an array might be an array type.
Index: dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java,v
retrieving revision 1.11
diff -u -r1.11 RecoveredTypeBinding.java
--- dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 27 Jun 2008 16:03:46 -0000 1.11
+++ dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 21 Jan 2009 11:37:06 -0000
@@ -89,6 +89,20 @@
}
/* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ITypeBinding#getGenericTypeOfWildcardType()
+ */
+ public ITypeBinding getGenericTypeOfWildcardType() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ITypeBinding#getRank()
+ */
+ public int getRank() {
+ return -1;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.jdt.core.dom.ITypeBinding#getComponentType()
*/
public ITypeBinding getComponentType() {
Index: model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java,v
retrieving revision 1.37
diff -u -r1.37 BindingKeyParser.java
--- model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java 27 Jun 2008 16:03:57 -0000 1.37
+++ model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java 21 Jan 2009 11:37:10 -0000
@@ -111,7 +111,7 @@
boolean isAtWildcardStart() {
return
this.index < this.source.length
- && "*+-".indexOf(this.source[this.index]) != -1; //$NON-NLS-1$
+ && this.source[this.index] == '{'; // e.g {1}+Ljava/lang/String;
}
boolean isAtTypeParameterStart() {
@@ -339,6 +339,12 @@
}
}
+ void skipRank() {
+ this.start = this.index;
+ while (this.index < this.source.length && "0123456789".indexOf(this.source[this.index]) != -1) //$NON-NLS-1$
+ this.index++;
+ }
+
void skipThrownStart() {
while (this.index < this.source.length && this.source[this.index] == C_THROWN)
this.index++;
@@ -359,6 +365,17 @@
if (this.index < this.source.length && this.source[this.index] == ';')
this.index++;
}
+
+ void skipRankStart() {
+ if (this.index < this.source.length && this.source[this.index] == '{')
+ this.index++;
+ }
+
+ void skipRankEnd() {
+ if (this.index < this.source.length && this.source[this.index] == '}')
+ this.index++;
+ this.start = this.index;
+ }
public String toString() {
StringBuffer buffer = new StringBuffer();
@@ -543,6 +560,10 @@
public void consumeWildCard(int kind) {
// default is to do nothing
}
+
+ public void consumeWildcardRank(int rank) {
+ // default is to do nothing
+ }
/*
* Returns the string that this binding key wraps.
@@ -883,6 +904,7 @@
}
private void parseWildcard() {
+ parseWildcardRank();
if (this.scanner.nextToken() != Scanner.WILDCARD) return;
char[] source = this.scanner.getTokenSource();
if (source.length == 0) {
@@ -910,6 +932,14 @@
consumeWildCard(kind);
}
+ private void parseWildcardRank() {
+ this.scanner.skipRankStart();
+ this.scanner.skipRank();
+ char[] source = this.scanner.getTokenSource();
+ consumeWildcardRank(Integer.parseInt(new String(source)));
+ this.scanner.skipRankEnd();
+ }
+
private void parseWildcardBound() {
BindingKeyParser parser = newParser();
parser.parse();
Index: model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java,v
retrieving revision 1.53
diff -u -r1.53 BindingKeyResolver.java
--- model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java 27 Jun 2008 16:03:56 -0000 1.53
+++ model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java 21 Jan 2009 11:37:11 -0000
@@ -64,8 +64,7 @@
TypeBinding typeBinding;
TypeDeclaration typeDeclaration;
ArrayList types = new ArrayList();
- int rank = 0;
-
+
int wildcardRank;
CompilationUnitDeclaration outerMostParsedUnit;
@@ -75,11 +74,10 @@
*/
HashtableOfObject resolvedUnits;
- private BindingKeyResolver(BindingKeyParser parser, Compiler compiler, LookupEnvironment environment, int wildcardRank, CompilationUnitDeclaration outerMostParsedUnit, HashtableOfObject parsedUnits) {
+ private BindingKeyResolver(BindingKeyParser parser, Compiler compiler, LookupEnvironment environment, CompilationUnitDeclaration outerMostParsedUnit, HashtableOfObject parsedUnits) {
super(parser);
this.compiler = compiler;
this.environment = environment;
- this.wildcardRank = wildcardRank;
this.outerMostParsedUnit = outerMostParsedUnit;
this.resolvedUnits = parsedUnits;
}
@@ -349,8 +347,6 @@
public void consumeParser(BindingKeyParser parser) {
this.types.add(parser);
- if (((BindingKeyResolver) parser).compilerBinding instanceof WildcardBinding)
- this.rank++;
}
public void consumeScope(int scopeNumber) {
@@ -430,6 +426,10 @@
this.typeBinding =(TypeBinding) resolver.compilerBinding;
}
+ public void consumeWildcardRank(int aRank) {
+ this.wildcardRank = aRank;
+ }
+
public void consumeWildCard(int kind) {
switch (kind) {
case Wildcard.EXTENDS:
@@ -438,7 +438,7 @@
this.typeBinding = this.environment.createWildcard((ReferenceBinding) this.typeBinding, this.wildcardRank, (TypeBinding) boundResolver.compilerBinding, null /*no extra bound*/, kind);
break;
case Wildcard.UNBOUND:
- this.typeBinding = this.environment.createWildcard((ReferenceBinding) this.typeBinding, this.rank++, null/*no bound*/, null /*no extra bound*/, kind);
+ this.typeBinding = this.environment.createWildcard((ReferenceBinding) this.typeBinding, this.wildcardRank, null/*no bound*/, null /*no extra bound*/, kind);
break;
}
}
@@ -576,7 +576,7 @@
}
public BindingKeyParser newParser() {
- return new BindingKeyResolver(this, this.compiler, this.environment, this.rank, this.outerMostParsedUnit == null ? this.parsedUnit : this.outerMostParsedUnit, this.resolvedUnits);
+ return new BindingKeyResolver(this, this.compiler, this.environment, this.outerMostParsedUnit == null ? this.parsedUnit : this.outerMostParsedUnit, this.resolvedUnits);
}
public String toString() {
Index: compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java,v
retrieving revision 1.70
diff -u -r1.70 WildcardBinding.java
--- compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java 27 Jun 2008 16:04:02 -0000 1.70
+++ compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java 21 Jan 2009 11:37:04 -0000
@@ -23,8 +23,8 @@
*/
public class WildcardBinding extends ReferenceBinding {
- ReferenceBinding genericType;
- int rank;
+ public ReferenceBinding genericType;
+ public int rank;
public TypeBinding bound; // when unbound denotes the corresponding type variable (so as to retrieve its bound lazily)
public TypeBinding[] otherBounds; // only positionned by lub computations (if so, #bound is also set) and associated to EXTENDS mode
char[] genericSignature;
@@ -341,12 +341,14 @@
}
/*
- * genericTypeKey *|+|- [boundKey]
- * p.X { X> ... } --> Lp/X;*
+ * genericTypeKey {rank}*|+|- [boundKey]
+ * p.X { X> ... } --> Lp/X;{0}*
*/
public char[] computeUniqueKey(boolean isLeaf) {
char[] genericTypeKey = this.genericType.computeUniqueKey(false/*not a leaf*/);
char[] wildCardKey;
+ // We now encode the rank also in the binding key - https://bugs.eclipse.org/bugs/show_bug.cgi?id=234609
+ char[] rankComponent = ('{' + String.valueOf(this.rank) + '}').toCharArray();
switch (this.boundKind) {
case Wildcard.UNBOUND :
wildCardKey = TypeConstants.WILDCARD_STAR;
@@ -358,8 +360,10 @@
wildCardKey = CharOperation.concat(TypeConstants.WILDCARD_MINUS, this.bound.computeUniqueKey(false/*not a leaf*/));
break;
}
- return CharOperation.concat(genericTypeKey, wildCardKey);
- }
+ return CharOperation.concat(genericTypeKey, rankComponent, wildCardKey);
+ }
+
+
/**
* @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#constantPoolName()