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 68031 Details for
Bug 188103
[1.5][compiler] Inappropriate usage of HashSet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
188103a.txt (text/plain), 8.35 KB, created by
Philipe Mulet
on 2007-05-21 18:15:55 EDT
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2007-05-21 18:15:55 EDT
Size:
8.35 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.630 >diff -u -r1.630 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 15 May 2007 14:39:20 -0000 1.630 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 21 May 2007 22:15:41 -0000 >@@ -31414,12 +31414,12 @@ > "1. WARNING in X.java (at line 4)\n" + > " List<Class<Object>> lco = Arrays.asList(String.class, Integer.class, Long.class);\n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Type safety : A generic array of Class<? extends Object&Comparable<?>&Serializable> is created for a varargs parameter\n" + >+ "Type safety : A generic array of Class<? extends Object&Serializable&Comparable<?>> is created for a varargs parameter\n" + > "----------\n" + > "2. ERROR in X.java (at line 4)\n" + > " List<Class<Object>> lco = Arrays.asList(String.class, Integer.class, Long.class);\n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Type mismatch: cannot convert from List<Class<? extends Object&Comparable<?>&Serializable>> to List<Class<Object>>\n" + >+ "Type mismatch: cannot convert from List<Class<? extends Object&Serializable&Comparable<?>>> to List<Class<Object>>\n" + > "----------\n"); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=91709 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.307 >diff -u -r1.307 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 16 May 2007 20:49:40 -0000 1.307 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 21 May 2007 22:15:46 -0000 >@@ -2536,12 +2536,12 @@ > nextCandidate: for (int k = 0, max = mecs.length; k < max; k++) { > TypeBinding mec = mecs[k]; > if (mec == null) continue nextCandidate; >- Set invalidInvocations = (Set) invocations.get(mec); >- int invalidSize = invalidInvocations.size(); >- if (invalidSize > 1) { >- TypeBinding[] collisions; >- invalidInvocations.toArray(collisions = new TypeBinding[invalidSize]); >- problemReporter().superinterfacesCollide(collisions[0].erasure(), typeRef, collisions[0], collisions[1]); >+ Object value = invocations.get(mec); >+ if (value instanceof List) { >+ List invalidInvocations = (List) value; >+ TypeBinding firstInvocation = (TypeBinding) invalidInvocations.get(0); >+ TypeBinding secondInvocation = (TypeBinding) invalidInvocations.get(1); >+ problemReporter().superinterfacesCollide(firstInvocation.erasure(), typeRef, firstInvocation, secondInvocation); > type.tagBits |= TagBits.HierarchyHasProblems; > return true; > } >@@ -2756,8 +2756,12 @@ > return false; > } > >- private TypeBinding leastContainingInvocation(TypeBinding mec, Set invocations, List lubStack) { >- if (invocations == null) return mec; // no alternate invocation >+ private TypeBinding leastContainingInvocation(TypeBinding mec, Object invocationValue, List lubStack) { >+ if (invocationValue == null) return mec; // no alternate invocation >+ if (!(invocationValue instanceof List)) { // only one invocation, simply return it (list only allocated if more than one) >+ return (TypeBinding) invocationValue; >+ } >+ List invocations = (List) invocationValue; > int length = invocations.size(); > Iterator iter = invocations.iterator(); > if (length == 1) return (TypeBinding) iter.next(); >@@ -2928,7 +2932,7 @@ > for (int i = 0; i < length; i++) { > TypeBinding mec = mecs[i]; > if (mec == null) continue; >- mec = leastContainingInvocation(mec, (Set)invocations.get(mec), lubStack); >+ mec = leastContainingInvocation(mec, invocations.get(mec), lubStack); > if (mec == null) return null; > int dim = mec.dimensions(); > if (commonDim == -1) { >@@ -3001,9 +3005,7 @@ > TypeBinding leafType = firstType.leafComponentType(); > TypeBinding firstErasure = (leafType.isTypeVariable() || leafType.isWildcard()/*&& !leafType.isCapture()*/) ? firstType : firstType.erasure(); > if (firstErasure != firstType) { >- Set someInvocations = new HashSet(1); >- someInvocations.add(firstType); >- allInvocations.put(firstErasure, someInvocations); >+ allInvocations.put(firstErasure, firstType); > } > typesToVisit.add(firstType); > int max = 1; >@@ -3063,9 +3065,7 @@ > max++; > TypeBinding superTypeErasure = (firstBound.isTypeVariable() || firstBound.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); > if (superTypeErasure != superType) { >- Set someInvocations = new HashSet(1); >- someInvocations.add(superType); >- allInvocations.put(superTypeErasure, someInvocations); >+ allInvocations.put(superTypeErasure, superType); > } > } > continue; >@@ -3082,9 +3082,7 @@ > max++; > TypeBinding superTypeErasure = (itsInterface.isTypeVariable() || itsInterface.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); > if (superTypeErasure != superType) { >- Set someInvocations = new HashSet(1); >- someInvocations.add(superType); >- allInvocations.put(superTypeErasure, someInvocations); >+ allInvocations.put(superTypeErasure, superType); > } > } > } >@@ -3097,9 +3095,7 @@ > max++; > TypeBinding superTypeErasure = (itsSuperclass.isTypeVariable() || itsSuperclass.isWildcard() /*&& !itsSuperclass.isCapture()*/) ? superType : superType.erasure(); > if (superTypeErasure != superType) { >- Set someInvocations = new HashSet(1); >- someInvocations.add(superType); >- allInvocations.put(superTypeErasure, someInvocations); >+ allInvocations.put(superTypeErasure, superType); > } > } > } >@@ -3128,10 +3124,24 @@ > continue nextSuperType; > } > // record invocation >- Set someInvocations = (Set) allInvocations.get(erasedSuperType); >- if (someInvocations == null) someInvocations = new HashSet(1); >- someInvocations.add(match); >- allInvocations.put(erasedSuperType, someInvocations); >+ Object value = allInvocations.get(erasedSuperType); >+ if (value == null) { >+ allInvocations.put(erasedSuperType, match); >+ } else if (!(value instanceof List)) { >+ if (match != value) { >+ // using a list to record invocations in order (188103) >+ List someInvocations = new ArrayList(2); >+ someInvocations.add(value); >+ someInvocations.add(match); >+ allInvocations.put(erasedSuperType, someInvocations); >+ } >+ } else { >+ List someInvocations = (List) value; >+ if (!someInvocations.contains(match)) { >+ someInvocations.add(match); >+ allInvocations.put(erasedSuperType, someInvocations); >+ } >+ } > } > continue nextOtherType; > } >@@ -3154,10 +3164,24 @@ > } > } > // record invocation >- Set someInvocations = (Set) allInvocations.get(erasedSuperType); >- if (someInvocations == null) someInvocations = new HashSet(1); >- someInvocations.add(match); >- allInvocations.put(erasedSuperType, someInvocations); >+ Object value = allInvocations.get(erasedSuperType); >+ if (value == null) { >+ allInvocations.put(erasedSuperType, match); >+ } else if (!(value instanceof List)) { >+ if (match != value) { >+ // using a list to record invocations in order (188103) >+ List someInvocations = new ArrayList(2); >+ someInvocations.add(value); >+ someInvocations.add(match); >+ allInvocations.put(erasedSuperType, someInvocations); >+ } >+ } else { >+ List someInvocations = (List) value; >+ if (!someInvocations.contains(match)) { >+ someInvocations.add(match); >+ allInvocations.put(erasedSuperType, someInvocations); >+ } >+ } > } > } > // eliminate non minimal super types
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 188103
:
67990
|
68019
|
68031
|
68073
|
68103