Bug 33754 - IJavaProject.isOnClasspath should answer false for working copies outside the classpath
Summary: IJavaProject.isOnClasspath should answer false for working copies outside the...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 2.1 RC2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, readme
Depends on:
Blocks:
 
Reported: 2003-03-04 10:12 EST by Philipe Mulet CLA
Modified: 2003-03-10 11:55 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2003-03-04 10:12:54 EST
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).
Comment 1 Jim des Rivieres CLA 2003-03-04 12:10:18 EST
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.

Comment 2 Philipe Mulet CLA 2003-03-04 12:34:42 EST
I fully agree, and JDT/UI said they were willing to go down that path too.
Comment 3 Philipe Mulet CLA 2003-03-04 13:21:03 EST
Made change to both flavors of IJavaProject.isOnClasspath(...).
Will send patch to JDT/UI for checking their behavior.

Fixed in latest
Comment 4 Jared Burns CLA 2003-03-05 12:41:37 EST
Philippe, will this change be in tomorrow's build (20030306)?
Comment 5 Philipe Mulet CLA 2003-03-06 08:46:15 EST
Yes, it is already in HEAD. 
Comment 6 David Audel CLA 2003-03-10 11:55:52 EST
Verified.