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 123066 Details for
Bug 234609
[dom] BindingKey#toSignature() fails with key from createWilcardTypeBindingKey(..)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch with review comments addressed
patch.txt (text/plain), 30.33 KB, created by
Srikanth Sankaran
on 2009-01-20 06:58:41 EST
(
hide
)
Description:
Patch with review comments addressed
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2009-01-20 06:58:41 EST
Size:
30.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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 20 Jan 2009 11:50:15 -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,49 @@ > } > > /** >+ * 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. >+ * <p> >+ * For example: >+ * <pre> >+ * <code> >+ * 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;" >+ * </code> >+ * </pre> >+ * </p> >+ * >+ * @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 >+ */ >+ >+ 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 20 Jan 2009 11:50:14 -0000 >@@ -163,7 +163,37 @@ > } > return null; > } >- >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.core.dom.ITypeBinding#getGenericType() >+ */ >+ public ITypeBinding getGenericType() { >+ 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 20 Jan 2009 11:50:11 -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 <code>null</code> if this is not a wildcard type. >+ * >+ * @return the generic type associated with this wildcard type, or <code>null</code> if none >+ * @see #isWildcardType() >+ * @since 3.5 >+ */ >+ public ITypeBinding getGenericType(); > > /** >+ * 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 <code>-1</code> if this is not a wildcard type. >+ * >+ * @return the rank associated with this wildcard type, or <code>-1</code> if none >+ * @see #isWildcardType() >+ * @since 3.5 >+ */ >+ public int getRank(); >+ >+ /** > * Returns the binding representing the component type of this array type, > * or <code>null</code> 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 20 Jan 2009 11:50:12 -0000 >@@ -89,6 +89,20 @@ > } > > /* (non-Javadoc) >+ * @see org.eclipse.jdt.core.dom.ITypeBinding#getGenericType() >+ */ >+ public ITypeBinding getGenericType() { >+ 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 20 Jan 2009 11:50:16 -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 20 Jan 2009 11:50:17 -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 20 Jan 2009 11:50:09 -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<T> { X<?> ... } --> Lp/X<TT;>;* >+ * genericTypeKey {rank}*|+|- [boundKey] >+ * p.X<T> { X<?> ... } --> Lp/X<TT;>;{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() >#P org.eclipse.jdt.core.tests.model >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 20 Jan 2009 11:50:47 -0000 >@@ -929,7 +929,7 @@ > " }\n" + > "}", > }, >- "Lp1/X<Lp1/X;*>;.foo()V"); >+ "Lp1/X<Lp1/X;{0}*>;.foo()V"); > } > > /* >@@ -948,7 +948,7 @@ > " }\n" + > "}", > }, >- "Lp1/X<Lp1/X;+Ljava/lang/Object;>;.foo()V"); >+ "Lp1/X<Lp1/X;{0}+Ljava/lang/Object;>;.foo()V"); > } > > /* >@@ -967,7 +967,7 @@ > " }\n" + > "}", > }, >- "Lp1/X<Lp1/X;-Ljava/lang/Error;>;.foo()V"); >+ "Lp1/X<Lp1/X;{0}-Ljava/lang/Error;>;.foo()V"); > } > > /* >@@ -986,7 +986,7 @@ > " }\n" + > "}", > }, >- "Lp1/X<Lp1/X;-Ljava/lang/Error;Lp1/X;*Ljava/lang/String;Lp1/X;+Ljava/lang/Object;>;.foo()V"); >+ "Lp1/X<Lp1/X;{0}-Ljava/lang/Error;Lp1/X;{1}*Ljava/lang/String;Lp1/X;{2}+Ljava/lang/Object;>;.foo()V"); > } > > /* >@@ -1036,7 +1036,7 @@ > " X<? super T> field;\n" + > "}", > }, >- "Lp1/X<Lp1/X;-Lp1/X;:TT;>;"); >+ "Lp1/X<Lp1/X;{0}-Lp1/X;:TT;>;"); > } > > /* >@@ -1052,7 +1052,7 @@ > " Class<? extends E> field;\n" + > "}", > }, >- "Ljava/lang/Class<Lp1/X;+Lp1/X;:TE;>;"); >+ "Ljava/lang/Class<Lp1/X;{0}+Lp1/X;:TE;>;"); > } > > /* >@@ -1073,12 +1073,12 @@ > }, > new String[] { > "Lp1/X;", >- "Lp1/Y<Lp1/Y;+Lp1/X;>;" >+ "Lp1/Y<Lp1/Y;{0}+Lp1/X;>;" > } > ); > assertBindingsEqual( > "Lp1/X;\n" + >- "Lp1/Y<Lp1/Y;+Lp1/X;>;", >+ "Lp1/Y<Lp1/Y;{0}+Lp1/X;>;", > bindings); > } > >@@ -1133,9 +1133,9 @@ > public void test050() throws CoreException { > ITypeBinding[] bindings = createTypeBindings( > new String[] {}, >- new String[] {"Ljava/lang/Class<Ljava/lang/Class<TT;>;+[Ljava/lang/Object;>;"}); >+ new String[] {"Ljava/lang/Class<Ljava/lang/Class<TT;>;{0}+[Ljava/lang/Object;>;"}); > assertBindingsEqual( >- "Ljava/lang/Class<Ljava/lang/Class;+[Ljava/lang/Object;>;", >+ "Ljava/lang/Class<Ljava/lang/Class;{0}+[Ljava/lang/Object;>;", > 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<T> extends Z<T> {\n" + > "}", > }, >- "Lp1/X;.foo<T:Lp1/Y<-TT;>;>(Lp1/Z<TT;>;)V%<Lp1/X~Y<Lp1/X~Y;-Lp1/X~Y<Lp1/X~Y;-Lp1/X;:2TT;>;>;>" >+ "Lp1/X;.foo<T:Lp1/Y<-TT;>;>(Lp1/Z<TT;>;)V%<Lp1/X~Y<Lp1/X~Y;{0}-Lp1/X~Y<Lp1/X~Y;{0}-Lp1/X;:2TT;>;>;>" > ); > } > >@@ -1461,7 +1461,7 @@ > }, > new String[] { > "Lp1/X;", >- "Lp1/X;&Lp1/Y<!Lp1/Y;*83;>;", >+ "Lp1/X;&Lp1/Y<!Lp1/Y;{0}*83;>;", > } > ); > } >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 20 Jan 2009 11:50:44 -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].getGenericType(); >+ if (gType == null) >+ fail("Missing generic type"); >+ if (!gType.getKey().equals("Ljava/util/HashMap<TK;TV;>;")) >+ 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<!Lp/X;*75;>;.foo()V", >+ "Lp/X<!Lp/X;{0}*75;>;.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;+LX;:TE;>;", >+ "Ljava/lang/Class<Ljava/lang/Class;{0}+LX;:TE;>;", > binding); > } > >@@ -10175,7 +10294,7 @@ > this.workingCopy); > IBinding binding = ((MethodInvocation) node).resolveTypeBinding(); > assertBindingKeyEquals( >- "Lpack1/E<Lpack1/E<!Lpack1/E;*122;>;>;", >+ "Lpack1/E<Lpack1/E<!Lpack1/E;{0}*122;>;>;", > binding.getKey()); > } > /* >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 20 Jan 2009 11:50:48 -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<TE;>;", Signature.C_SUPER); >+ String key = getWildcardBindingKey("Ljava/util/List<TE;>;", Signature.C_SUPER); > assertBindingKeyEquals( > "-Ljava/util/List<TE;>;", > 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<TT;>;", >- "Lp1/X;-Ljava/util/List<Lp1/X;:TT;>;" >+ "Lp1/X;{0}-Ljava/util/List<Lp1/X;:TT;>" > ); > } > >@@ -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<TT;>;", >- "Ljava/util/List;&!Lp1/X;-Ljava/util/List<Lp1/X;:TT;>;123;" >+ "Ljava/util/List;&!Lp1/X;{0}-Ljava/util/List<Lp1/X;:TT;>;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<!LX~Box;*232;!LX~Box;*232;>;.value)!LX~Box;*232;" >+ "LX;&LX~Box<!LX~Box;{0}*232;!LX~Box;{1}*232;>;.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 20 Jan 2009 11:51:12 -0000 >@@ -6082,7 +6082,7 @@ > > assertResults( > "expectedTypesSignatures={Ltest0191.ZZClass1<+TU;>;}\n" + >- "expectedTypesKeys={Ltest0191/Test~ZZClass1<Ltest0191/Test~ZZClass1;+Ltest0191/Test;:TU;>;}", >+ "expectedTypesKeys={Ltest0191/Test~ZZClass1<Ltest0191/Test~ZZClass1;{0}+Ltest0191/Test;:TU;>;}", > 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 20 Jan 2009 11:51:16 -0000 >@@ -2109,7 +2109,7 @@ > > assertElementsEqual( > "Unexpected elements", >- "Y {key=Ltest0095/X~Y<Ltest0095/X~Y;*Ltest0095/X~Y;+Ltest0095/X~Z<Ltest0095/X~Z;-Ljava/lang/Exception;>;>;} [in [Working copy] X.java [in test0095 [in src2 [in Resolve]]]]", >+ "Y {key=Ltest0095/X~Y<Ltest0095/X~Y;{0}*Ltest0095/X~Y;{1}+Ltest0095/X~Z<Ltest0095/X~Z;{0}-Ljava/lang/Exception;>;>;} [in [Working copy] X.java [in test0095 [in src2 [in Resolve]]]]", > elements, > true/*show key*/ > );
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 234609
:
122674
|
123066
|
123244