Community
Participate
Working Groups
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)
bug in J Core: codeSelect is speced to return JME and not IAE
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.
Created attachment 10999 [details] spec update spec update
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.
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.
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.
Created attachment 11148 [details] reverting to JavaModelException This patch replace IllegalArgumentException with JavaModelExcpetion
Created attachment 11149 [details] java model test update
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.
Fixed and released Tests updated CompletionTests#testCompletionOutOfBounds ResolveTests#testInvalidResolve
David, could you please verify this one?
Verified for 3.0RC1