Bug 229636 - JavaModelException should stay instanciatable
Summary: JavaModelException should stay instanciatable
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 RC1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-30 10:43 EDT by Martin Aeschlimann CLA
Modified: 2008-05-13 10:26 EDT (History)
4 users (show)

See Also:
jerome_lanneluc: review+


Attachments
Proposed fix (829 bytes, patch)
2008-05-05 15:31 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2008-04-30 10:43:57 EDT
20080430-0100

In v_856, the spec of JavaModelException was changed:

Old:
 * This class is not intended to be subclassed by clients. Instances of this
 * class are automatically created by the Java model when problems arise, so
 * there is generally no need for clients to create instances.

New:
 * @noinstantiate This class is not intended to be instantiated by clients.
 * @noextend This class is not intended to be subclassed by clients.

The old one did not forbid instantiating, only mentioning that there 'generally no need'. The new spec says 'noinstantiate'. We have several places in refactoring where JavaModelExceptions are instanciated using the jdt.core error constants.

Note that such fine differences are hard to detect as the old comment got replaces by the new tags. I think it's better to keep the old comment so it's easy to see that the change is not a change of rules.
Comment 1 Jerome Lanneluc CLA 2008-04-30 10:51:12 EDT
The contract was not extracted from the comment, but from the component.xml.
I agree that this contract was not obvious to clients, but the intent has never been to allow clients to instanciate this class.
Comment 2 Martin Aeschlimann CLA 2008-04-30 11:41:39 EDT
I can't really say if it was a good idea to instantiate JavaModelException.
But what's important here is what the Javadoc on the type declaration said.
The component.xml is overruled by that in case of a conflict. 
Comment 3 Jerome Lanneluc CLA 2008-04-30 11:55:03 EDT
(In reply to comment #0)
> Note that such fine differences are hard to detect as the old comment got
> replaces by the new tags. I think it's better to keep the old comment so it's
> easy to see that the change is not a change of rules.

Actually I'm still seeing the old comment in I20080430-0100:
 * Instances of this class are automatically created by the Java model
 * when problems arise, so there is generally no need for clients to create
 * instances.
Comment 4 Olivier Thomann CLA 2008-04-30 12:53:03 EDT
The "@noinstantiate This class is not intended to be instantiated by clients" will trigger the API usage error.
I can remove that line if Jérôme agrees. As Jérôme mentioned, it comes from the component.xml file.

The old specification didn't explicitly forbid to create instances.
 * Instances of this class are automatically created by the Java model
 * when problems arise, so there is generally no need for clients to create
 * instances.

So we should remove the @noinstantiate.

Jérôme, Philippe ?
Comment 5 Jerome Lanneluc CLA 2008-04-30 18:01:46 EDT
If we are saying that the Javadoc takes precedence over the component.xml, then I agree we should remove @noinstanciate.
Comment 6 Olivier Thomann CLA 2008-05-04 19:51:48 EDT
Jérôme,

+1 for 3.4RC1?
Comment 7 Jerome Lanneluc CLA 2008-05-05 01:47:44 EDT
+1
Comment 8 Olivier Thomann CLA 2008-05-05 15:31:25 EDT
Created attachment 98696 [details]
Proposed fix
Comment 9 Olivier Thomann CLA 2008-05-05 15:32:05 EDT
Jérôme, please review patch.
Thanks.
Comment 10 Olivier Thomann CLA 2008-05-05 23:22:01 EDT
Released for 3.4RC1.
Comment 11 David Audel CLA 2008-05-13 10:26:03 EDT
Verified for 3.4RC1 using I20080510-2000