Bug 204777 - Clarify documentation for ITypeHierarchy created on interface types
Summary: Clarify documentation for ITypeHierarchy created on interface types
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-27 05:46 EDT by Dani Megert CLA
Modified: 2009-08-04 07:15 EDT (History)
2 users (show)

See Also:


Attachments
Regression test (1.57 KB, patch)
2007-09-27 06:48 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Proposed patch (1.47 KB, patch)
2009-07-07 08:00 EDT, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2007-09-27 05:46:46 EDT
I20070925-0919.

ITypeHierarchy.contains(<Object>) returns 'true' for interface hierarchies. This seems wrong as ITypeHierarchy.getAllSupertypes() says:
 * Note that <code>java.lang.Object</code> is NOT considered to be a supertype 
 * of any interface type.


NOTE: fixing this might cause severe breakage on clients. Maybe the only fix is to document this in the Javadoc.


Test Case:
IJavaElement runnable= JavaModelUtil.findType(aJavaProject, "java.lang.Runnable");
IJavaElement object= JavaModelUtil.findType(aJavaProject, "java.lang.Object");
ITypeHierarchy th= ((IType)runnable).newSupertypeHierarchy(null);
th.contains((IType)object) ==> true
Comment 1 Dani Megert CLA 2007-09-27 05:47:40 EDT
Sorry build id was wrong. Correct is: I20070925-1406.
Comment 2 Jerome Lanneluc CLA 2007-09-27 06:48:22 EDT
Created attachment 79273 [details]
Regression test

This test shows the current problem. I'm not sure why someone be broken by a fix, but since no one else reported the problem, I'm lowering the priority of this bug.
Comment 3 Dani Megert CLA 2007-09-27 06:59:02 EDT
>I'm not sure why someone be broken by a fix,
For example if you used such code to test whether IType X is assignement compatbile with IType Y: X.newSupertypeHierarchy(null).contains(Y).
Comment 4 Olivier Thomann CLA 2009-06-26 11:13:30 EDT
I would be tempted to only fix the javadoc as it can indeed break existing clients.
Comment 5 Dani Megert CLA 2009-06-26 11:18:48 EDT
Right. just fix the comment.
Comment 6 Srikanth Sankaran CLA 2009-07-07 08:00:06 EDT
Created attachment 140948 [details]
Proposed patch

th.getRootClasses(), th.getAllTypes() and th.getAllClasses() also return
the IType corresponding to java.lang.Object. So it seems fair to say that
interface hierarchies always contain java.lang.Object, except that the
get*Super*() methods filter it out as they claim in the documentation.

I have added a note in the javadoc for ITypeHierarchy to the effect that 
"As a historical quirk, java.lang.Object has always been included in type hierarchies created on interface types."
Comment 7 Srikanth Sankaran CLA 2009-07-08 02:40:22 EDT
Released in HEAD for 3.6M1
Comment 8 Frederic Fusier CLA 2009-08-04 07:15:30 EDT
Verified for 3.6M1