This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I've seen this bug for several months, off and on. It appears to be a race condition, because it does not occur reproducibly. Every now and then when I start the debugger and the editor is started (to show the current location), I get the below exception thrown. This produces a popup dialog with an exception which is unnerving to the user. It doesn't seem to "cause anything bad" to happen however. I used to think perhaps this was due to a bug in my own editor kit (since I typically load up C++ source files), but right now it happened when I loaded in a Java file. I've mentioned this bug and provided a stacktrace to David (Konecny) before, and he suggested I file a bug if it occurs again with fresh sources. And today's occurrence happened with a brand new build from sources. java.lang.IllegalArgumentException: Line index=-1 must be >= 0 at org.netbeans.editor.BaseDocument$LineRootElement.getElement(BaseDocument.java:1127) at org.openide.text.NbDocument.findLineOffset(NbDocument.java:116) at org.openide.text.PositionRef$Manager$LineKind.toMemory(PositionRef.java:516) at org.openide.text.PositionRef$Manager.documentOpened(PositionRef.java:242) at org.openide.text.CloneableEditorSupport$Listener.run(CloneableEditorSupport.java:1387) at org.openide.util.Task.run(Task.java:152) at org.openide.text.CloneableEditorSupport$1.run(CloneableEditorSupport.java:302) at org.openide.util.Task.run(Task.java:152) at java.lang.Thread.run(Thread.java:484) Thu Oct 18 09:21:22 PDT 2001: java.lang.IllegalArgumentException: Line index=-1 must be >= 0 java.lang.IllegalArgumentException: Line index=-1 must be >= 0 at org.netbeans.editor.BaseDocument$LineRootElement.getElement(BaseDocument.java:1127) at org.openide.text.NbDocument.findLineOffset(NbDocument.java:116) at org.openide.text.PositionRef$Manager$LineKind.toMemory(PositionRef.java:516) at org.openide.text.PositionRef$Manager.documentOpened(PositionRef.java:242) at org.openide.text.CloneableEditorSupport$Listener.run(CloneableEditorSupport.java:1387) at org.openide.util.Task.run(Task.java:152) at org.openide.text.CloneableEditorSupport$1.run(CloneableEditorSupport.java:302) at org.openide.util.Task.run(Task.java:152) [catch] at java.lang.Thread.run(Thread.java:484)
Hi Tor, I think that we need some further steps to reproduce it e.g. if you set some breakpoint etc. The problem is that there are some "bad" positionrefs created for the document. Once the editor gets opened their original positions cannot be restored. The editor is not involved very much in this problem because although the editor throws the exception it cannot do anything reasonable because it gets asked to return the line-element for the line with index -1. There must be some code in PositionRef in the openide that will decide what should be done once the position cannot be restored. Reassigning to openide.
Assigning.
Fixed in [main-trunk]. I looked at the code and there seems to be only way to get PostionRef to invalid state. And that is if there is a StyledDocument which Position getOffset() returns -1, which is wrong. (Then this value is internally used as flag which then confuses PositionRef later). Now this condition should be handled. When serializing such invalid PositionRef it will thrown IOException which describes the problematic Position, StyledDocument and also CloneableEditorSupport instances. Thus such invalid PostionRef won't be serialized and when deserializing not incorrectly recognized as another kind (the flag) of PositionRef. So you shouldn't get your exception anymore. But you should get the IOException decsribing the problematic StyledDocument&Position. Then file an issue against their implementors. Fix: openide/../openide/text/PositionRef.java [1.38] /Bundle.properties [1.32]
#20011023
- only for sustaining team [Jumbo_Patch 3.2] IndexOutOfBoundsException arise again on FFJ3.0 with JP3.2. IMHO : This issue cause impossibility to save file which you were open -> data lost! By the way , this one is the same as issue 13385.
Resolved for 3.4.x or earlier, no new info since then -> closing.