Bug 239096 - Implementation oddness in TypeHierarchy#getAllSuper*(IType)
Summary: Implementation oddness in TypeHierarchy#getAllSuper*(IType)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 trivial (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-01 06:32 EDT by Markus Keller CLA
Modified: 2008-09-15 10:03 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix and tests (5.08 KB, patch)
2008-08-21 12:52 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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