Community
Participate
Working Groups
Wrong fullyQualifiedName for inner classes In the following example there exist two anonymous inner classes with the fullyQualifiedName=="test.Directories$1" which is wrong. This is because org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor.resolveDuplicat es(SourceRefElement handle) doesnt increment the occurenceCount of a newly created type because of a wrong implementation of equals() of org.eclipse.jdt.internal.core.SourceType if there are two inner classes which are not declared in the same method. Because of this two different sourceTypes with the same occurenceCount=1 are created. Example: package test; public class Directories { public static final Interface i2 = new Interface(){}; public static final Interface i3 = new Interface(){}; } I fixed this problem with the following corrections in SourceType.java: - additional implementation: public int hashCode() { return Util.combineHashCodes(getElementName().hashCode(), this.occurrenceCount); } - changed implementation of equals(o): public boolean equals(Object o) { if (!(o instanceof SourceType)) return false; SourceType other = (SourceType) o; boolean namesAndOccurence = getElementName().equals(other.getElementName ()) && this.occurrenceCount == other.occurrenceCount; if(!namesAndOccurence) { return false; } else { JavaElement thisCompilationUnit = getCompilationUnit(this); JavaElement otherCompilationUnit = getCompilationUnit(other); return thisCompilationUnit.equals(otherCompilationUnit); } } private static JavaElement getCompilationUnit(JavaElement javaElement) { if(javaElement instanceof CompilationUnit) { return javaElement; } if(javaElement.parent != null) { return getCompilationUnit(javaElement.parent); } else { return null; } }
fixed in version 3.1M5a
Verified.