Bug 239096

Summary: Implementation oddness in TypeHierarchy#getAllSuper*(IType)
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: trivial    
Priority: P3 CC: Olivier_Thomann
Version: 3.4   
Target Milestone: 3.5 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix and tests none

Description Markus Keller CLA 2008-07-01 06:32:52 EDT
HEAD of TypeHierarchy#getAllSuperInterfaces(IType) and #getAllSupertypes(IType) start with:
	ArrayList supers = new ArrayList();
	if (this.typeToSuperInterfaces.get(type) == null) {
		return NO_TYPE;
	}

It looks like typeToSuperInterfaces.get(type) is an empty array if the type is in the hierarchy but has not super interfaces.
=> The optimization only works for types that are not in the hierarchy.

In #getAllSupertypes(IType), the check for emptiness would even be wrong if it worked, since the method would return an empty array even if the type is a subclass of Object.
Comment 1 Jerome Lanneluc CLA 2008-08-21 12:52:29 EDT
Created attachment 110592 [details]
Proposed fix and tests

This fix returns the empty array NO_TYPE if the type has no super types/interfaces or if it doesn't exit in the hierarchy. It also avoids the creation of the ArrayList object if threre is no super types/interfaces.
Comment 2 Jerome Lanneluc CLA 2008-08-21 12:55:25 EDT
Fix and tests released for 3.5M2
Comment 3 Olivier Thomann CLA 2008-09-15 10:03:31 EDT
Verified for 3.5M2 using I20080914-2000