Bug 46052 - result of ITypeHierarchy.getAllSuperTypes() does not include Object
Summary: result of ITypeHierarchy.getAllSuperTypes() does not include Object
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-04 14:10 EST by Frank Tip CLA
Modified: 2003-11-24 07:16 EST (History)
1 user (show)

See Also:


Attachments
plugin with ChangeType refactoring (47.65 KB, application/x-compressed)
2003-11-10 09:44 EST, Frank Tip CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Tip CLA 2003-11-04 14:10:28 EST
The result of ITypeHierarchy.getAllSuperTypes() does not include an
IType for java.lang.Object. This is completely counterintuitive, 
because Object is a supertype of any other type.

  -Frank
Comment 1 Jerome Lanneluc CLA 2003-11-05 12:17:45 EST
It does for me. Do you have more details on how to recreate this problem?
Comment 2 Frank Tip CLA 2003-11-05 22:31:34 EST
Jerome,

The problem appears in the context of the "Change Type" refactoring that
I'm implementing. If you like, I can send you a ZIP file containing the
entire plugin, so you can experiment with it. The offending piece of code
looks as follows. If I comment out the second if statement, the behavior
of the program changes (which it shouldn't, right?)

  -Frank

/**
 * Returns true if and only if type1 is a direct or indirect subtype of type2.
 */
public boolean isSubTypeOf(IType type1, IType type2, IProgressMonitor pm) {
	if (type1.equals(type2))
		return true;	
	if (type2.getFullyQualifiedName().equals("java.lang.Object")) // workaround for
bug #46052
		return true;
		
	IType[] superTypes= fTypeHierarchy.getAllSupertypes(type1);
	for (int i= 0; i < superTypes.length; i++) {
		if (superTypes[i].equals(type2))
			return true;
	}
        return false;
}

  -Frank
Comment 3 Jerome Lanneluc CLA 2003-11-06 16:25:08 EST
Please attach the ZIP to this bug report, or if it is too big, please send it 
to me. BTW which Eclipse build are you using?
Comment 4 Adam Kiezun CLA 2003-11-08 18:23:39 EST
the problem is only visible for interfaces, see bug 23656
Comment 5 Frank Tip CLA 2003-11-10 09:44:50 EST
Created attachment 6709 [details]
plugin with ChangeType refactoring

Jerome,

I'm attaching a plugin with the new "Change Type" refactoring.
To reproduce the bug, you can run the unit tests in class 
ChangeTypeRefactoringTests in com.ibm.waton.refactoring.tests. 
These tests should all succeed. However, if you comment out the
line in class ChangeTypeRefactoring with the comment, "workaround for bug
#46052" a few of the tests will break.

This plugin works with M4. You will need to download the appropriate versions
of the tests for the jdt.ui and jdt.ui.refactoring plugins from
dev.eclipse.org.

Hope this helps,

  -Frank
Comment 6 Jerome Lanneluc CLA 2003-11-12 09:31:37 EST
Thanks for the test case Frank. But this works as designed. For an interface, 
only interfaces that the interface extends are returned. See the spec in 
ITypeHierarchy.getSupertypes(IType).

Note as said in bug 23656, we had this discussion on the jdt-core-dev mailing 
list before. Unless you have a strong use case, we cannot change the spec and 
we will have to live with this inconsitency.

Ok to close?
Comment 7 Frank Tip CLA 2003-11-14 13:30:21 EST
Jerome,

When I look at the JavaDoc in class ITypeHierarchy, this "designed" behavior
is not at all obvious to me, especially given that the name of the method is
  "get*All*SuperTypes".

Therefore, I suggest adding the following sentence to the JavaDoc for method
ITypeHierarchy.getAllSuperTypes(IType type):
  "Please note that java.lang.Object is NOT considered to be a supertype
   of any interface type."

regards,

  -Frank
Comment 8 Jerome Lanneluc CLA 2003-11-17 04:47:29 EST
Thanks Frank. I have updated the Java doc to include your comments.
Comment 9 David Audel CLA 2003-11-24 07:16:07 EST
Verified.