Community
Participate
Working Groups
Build 20030227 The current implementation of #isOnClasspath will quite easily throw a JavaModelException: e.g. when the project handle doesn't have the Java nature. This is somewhat inconsistent with IJavaModel.contains, which would simply answer a boolean in the same scenario. We cannot change the signature to remove JavaModelExceptions, since this would be a source compatibility issue, however we should probably answer 'false' in case the project/resource doesn't exist (in the JavaModel meaning).
It is difficult for clients to work with predicates that throw exceptions. It would be more consistent for IJavaProject.isOnClasspath to return false rather than throw any exception. The @exception tag and throws JavaModelException clause should be removed from this method, and the implementation changes so that it returns false in all cases where it was throwning JavaModelException. Although this change creates a source incompatibility, the change is binary compatible with 2.0 and within the original spirit of the original API contract. Include in 2.1 readme.
I fully agree, and JDT/UI said they were willing to go down that path too.
Made change to both flavors of IJavaProject.isOnClasspath(...). Will send patch to JDT/UI for checking their behavior. Fixed in latest
Philippe, will this change be in tomorrow's build (20030306)?
Yes, it is already in HEAD.
Verified.