Community
Participate
Working Groups
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
Sorry build id was wrong. Correct is: I20070925-1406.
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.
>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).
I would be tempted to only fix the javadoc as it can indeed break existing clients.
Right. just fix the comment.
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."
Released in HEAD for 3.6M1
Verified for 3.6M1