Bug 63077 - IllegalArgumentException in Openable.codeSelect
Summary: IllegalArgumentException in Openable.codeSelect
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: Sun Solaris
: P3 normal (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-19 15:14 EDT by Douglas Pollock CLA
Modified: 2004-06-01 04:51 EDT (History)
3 users (show)

See Also:


Attachments
spec update (5.30 KB, text/plain)
2004-05-24 06:17 EDT, David Audel CLA
no flags Details
reverting to JavaModelException (1.43 KB, text/plain)
2004-05-26 13:17 EDT, David Audel CLA
no flags Details
java model test update (1.61 KB, text/plain)
2004-05-26 13:19 EDT, David Audel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Pollock CLA 2004-05-19 15:14:26 EDT
I200405190010, Solaris 8, CDE, Motif

Deleting text from a java editor.


java.lang.IllegalArgumentException: Selected range (2046, 2053) is not located
in supplied source range (0, 2017)
        at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:138)
        at
org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:300)
        at
org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:294)
        at
org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:108)
        at
org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
        at
org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
        at
org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:161)
Comment 1 Dani Megert CLA 2004-05-20 07:33:37 EDT
bug in J Core: codeSelect is speced to return JME and not IAE
Comment 2 Philipe Mulet CLA 2004-05-24 05:51:35 EDT
According to spec, IllegalArgumentException can occur, when requestor is null. 
The spec however omits to declare that such an exception can occur when the 
completion/selection positions are out of the buffer bounds.

This is an error on client's end, for which IllegalArgumentException is meant.

Will request PMC approval to fix the spec, and have it match the 
implementation (implementation has been sending this exception since 20030910).

David please attach the proposed change to spec as a patch.
Comment 3 David Audel CLA 2004-05-24 06:17:17 EDT
Created attachment 10999 [details]
spec update

spec update
Comment 4 Philipe Mulet CLA 2004-05-24 10:22:52 EDT
Requested PMC approval:

Problem is that our spec doesn't mention IllegalArgumentException when 
completion/location is out of the bounds of the unit source. The 
implementation did change on 20030910. It used to be throwing a 
JavaModelException (pre sept. 2003), and now does instead throw an 
IllegalArgumentException, but we did forget to change the spec accordingly. 
This only denotes a situation where client is out of sync with resource 
contents, which is the reason why we did change to IllegalArgumentException.
Note that we had already spec'ed a scenario where IllegalArgumentException
was thrown (if requestor was null), so this isn't an entirely new scenario 
where clients should now be protecting themselves.
Comment 5 Jim des Rivieres CLA 2004-05-25 18:13:50 EDT
The spec for ICodeAssist.codeSelect very clearly states that 
JavaModelException is thrown if the range specified is not within the 
element's source range. The change to the behavior made in 20030910 introduced 
a bug. Changing the API spec as proposed would be a breaking API change for 
2.1 clients.
Comment 6 Philipe Mulet CLA 2004-05-26 12:14:45 EDT
David did investigate reverting to JavaModelException, and all looks good. We 
will thus proceed to be backward compatible. No need to change the spec any 
longer.
Comment 7 David Audel CLA 2004-05-26 13:17:00 EDT
Created attachment 11148 [details]
reverting to JavaModelException

This patch replace IllegalArgumentException with JavaModelExcpetion
Comment 8 David Audel CLA 2004-05-26 13:19:00 EDT
Created attachment 11149 [details]
java model test update
Comment 9 Jim des Rivieres CLA 2004-05-26 14:10:50 EDT
David,  Since the plan is to bring the implementation back in line with the 
long-standing spec, the patches can be applied, tested, and released anytime.
Comment 10 David Audel CLA 2004-05-27 06:07:07 EDT
Fixed and released

Tests updated
  CompletionTests#testCompletionOutOfBounds
  ResolveTests#testInvalidResolve
Comment 11 Olivier Thomann CLA 2004-05-28 16:04:34 EDT
David, could you please verify this one?
Comment 12 David Audel CLA 2004-06-01 04:51:51 EDT
Verified for 3.0RC1