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.
java.lang.IndexOutOfBoundsException: Line index=-2 must be >= 0 at org.netbeans.editor.BaseDocument$LineRootElemen t.getElement(BaseDocument.java:1139) at org.openide.text.NbDocument.findLineOffset (NbDocument.java:127) at org.openide.text.DocumentLine$Set.getCurrent (DocumentLine.java:754) at org.netbeans.modules.java.parser.ParserAnnotati on.attachToLineSet(ParserAnnotation.java:133) at org.netbeans.modules.java.JavaEditor.processAnn otations(JavaEditor.java:452) at org.netbeans.modules.java.JavaEditor.access$400 (JavaEditor.java:80) [catch] at org.netbeans.modules.java.JavaEditor$2.run (JavaEditor.java:230) at java.awt.event.InvocationEvent.dispatch (InvocationEvent.java:149) at java.awt.EventQueue.dispatchEvent (EventQueue.java:332) at java.awt.EventDispatchThread.pumpOneEventForHie rarchy(EventDispatchThread.java:126) at java.awt.EventDispatchThread.pumpEventsForHiera rchy(EventDispatchThread.java:93) at java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:88) at java.awt.EventDispatchThread.run (EventDispatchThread.java:80)
Created attachment 9723 [details] IDE log
It appears that getElement(-2) gets called on line root element. I've tried to find out what's the culprit but it appears that getCurret() in DocumentLine accepts even a negative line value so it's necessary to search in ParserAnnotation. I have docline=lines.getCurrent(line-1); on the line from the exception (not sure whether it's up-to-date or not) so in theory it's possible to get a negative value although the original value still had to be -1. I should note that I've changed BaseDocument's line root element's getElement() method to throw IOOBE to adhere to javax.swing.text.AbstractDocument functionality so it might be the reason why this exception did not appear in the past.
*** This issue has been marked as a duplicate of 26549 ***