Community
Participate
Working Groups
I20060816-1200 IClassFile#getType() is a handle-only query and should therefore not throw a JavaModelException. The implementation in ClassFile already doesn't throw the JME.
Removing "throws JavaModelException" would not break binary compatibility, according to JLS3, 13.4.21. However, since it breaks source compatibility, the change should be announced on the jdt-core list and added to the migration guide.
+1
And the Javadoc should mention that this is a handle-only method.
To be clear, are you saying that the method *can't* throw the exception, so it should be removed?
Yes, it can't. And clients aren't allowed to implement IClassFile on their own.
Created attachment 59666 [details] Proposed patch
Created attachment 59676 [details] New proposed patch Sorry, I posted the previous patch too quickly...
The source compatibility issue is a bit annoying... is it worth the pain ? or simply nice to have (I suspect we also have some predicates affected with the same issue e.g. IJavaElement#isStructureKnown()).
IJavaElement#isStructureKnown() is different, since it is not a handle-only method (that the return type is boolean does not matter, otherwise you could also justify an exists() guard for all other non-handle methods). It's up to the JDT/Core team to decide whether there are other hidden handle-only methods -- that's just the one I stumbled upon. It's not essential (the workaround is just an empty try-catch handler), but it would streamline some call sites.
I was looking for more instances of slight inconsistencies where predicate where throwing exception, but I think we cleaned most of them along the way, and simply missed this one. Therefore, +1.
Affected clients in the SDK outside of JDT/Core and JDT/UI are: org.eclipse.ant.internal.ui.datatransfer.ExportUtil.computeScope(Object) org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv.getPackage(String) org.eclipse.jdt.internal.debug.ui.TypeNameResolver.getType(IJavaElement) /org.eclipse.jdt.doc.isv/porting/3.3/incompatibilities.html (does not yet exist)
Created attachment 59998 [details] Proposed 3.3 porting addition Not sure whether the 3.2 porting guide should still be in 3.3 or not?
> Not sure whether the 3.2 porting guide should still be in 3.3 or not? The 3.2 porting guide is still relevant, so it should stay (cf. org.eclipse.platform.doc.isv/porting) Typo: "In Eclipse 3.2, the method IClassFile.getType() thrown a ..." => should be "threw a" I would also add that this is only a source incompatibility. Compiled class files still work fine.
Created attachment 60151 [details] New proposed 3.3 porting addition
Released for 3.3 M6 in HEAD stream. Walter, I've also released the necessary APT change in org.eclipse.jdt.apt project. Darin, Markus, Do not forget to release your corresponding changes today, thanks
Fixed JDT/UI references in HEAD. In some cases, I even simplified the code to ITypeRoot.findPrimaryType() (no branching for compilation units and class files any more).
Fixed debug reference
Verified for 3.3 M6 using build I20070320-0010