#3766 ArrayIndexOutOfBoundsException with Clipboard Copy Lines

closed-fixed
None
5
2013-01-09
2012-12-16
Bao N. Nguyen
No

The following steps will throw an ArrayIndexOutOfBoundsException in JEdit 5.0.0

1. Start jEdit with an empty file
2. Follow the menu Macro/Clipoard/Copy Lines

Exception trace

java.lang.ArrayIndexOutOfBoundsException: 0:1
at org.gjt.sp.jedit.buffer.JEditBuffer.getText(JEditBuffer.java:582)
at org.gjt.sp.jedit.textarea.TextArea.getText(TextArea.java:1299)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.gjt.sp.jedit.bsh.Reflect.invokeMethod(Reflect.java:134)
at org.gjt.sp.jedit.bsh.Reflect.invokeObjectMethod(Reflect.java:80)
at org.gjt.sp.jedit.bsh.Name.invokeMethod(Name.java:855)
at org.gjt.sp.jedit.bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at org.gjt.sp.jedit.bsh.BSHVariableDeclarator.eval(BSHVariableDeclarator.java:86)
at org.gjt.sp.jedit.bsh.BSHTypedVariableDeclaration.eval(BSHTypedVariableDeclaration.java:84)
at org.gjt.sp.jedit.bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at org.gjt.sp.jedit.bsh.BSHBlock.eval(BSHBlock.java:80)
at org.gjt.sp.jedit.bsh.BshMethod.invokeImpl(BshMethod.java:362)
at org.gjt.sp.jedit.bsh.BshMethod.invoke(BshMethod.java:258)
at org.gjt.sp.jedit.bsh.BshMethod.invoke(BshMethod.java:186)
at org.gjt.sp.jedit.bsh.Name.invokeLocalMethod(Name.java:914)
at org.gjt.sp.jedit.bsh.Name.invokeMethod(Name.java:801)
at org.gjt.sp.jedit.bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at org.gjt.sp.jedit.bsh.Interpreter.eval(Interpreter.java:644)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:339)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:287)
at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:213)
at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.java:1151)
at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:573)
at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:342)
at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:3386)
at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:1)
at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:212)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:374)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:829)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:873)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6389)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3268)
at java.awt.Component.processEvent(Component.java:6154)
at java.awt.Container.processEvent(Container.java:2045)
at java.awt.Component.dispatchEventImpl(Component.java:4750)
at java.awt.Container.dispatchEventImpl(Container.java:2103)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
at java.awt.Container.dispatchEventImpl(Container.java:2089)
at java.awt.Window.dispatchEventImpl(Window.java:2518)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
at java.awt.EventQueue.access$400(EventQueue.java:96)
at java.awt.EventQueue$2.run(EventQueue.java:631)
at java.awt.EventQueue$2.run(EventQueue.java:629)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
at java.awt.EventQueue$3.run(EventQueue.java:645)
at java.awt.EventQueue$3.run(EventQueue.java:643)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

Discussion

  • Bao N. Nguyen
    Bao N. Nguyen
    2012-12-16

    • summary: ArrayIndexOutOfBoundsException with Clipboard Copy lines --> ArrayIndexOutOfBoundsException with Clipboard Copy Lines
     
  • Bao N. Nguyen
    Bao N. Nguyen
    2012-12-16

    A similar bug with Cut Lines

    Exception trace
    java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
    at org.gjt.sp.jedit.buffer.JEditBuffer.getLineOfOffset(JEditBuffer.java:332)
    at org.gjt.sp.jedit.textarea.TextArea.getLineOfOffset(TextArea.java:1253)
    at org.gjt.sp.jedit.textarea.SelectionManager.addToSelection(SelectionManager.java:133)
    at org.gjt.sp.jedit.textarea.SelectionManager.setSelection(SelectionManager.java:164)
    at org.gjt.sp.jedit.textarea.TextArea.setSelection(TextArea.java:1771)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.gjt.sp.jedit.bsh.Reflect.invokeMethod(Reflect.java:134)
    at org.gjt.sp.jedit.bsh.Reflect.invokeObjectMethod(Reflect.java:80)
    at org.gjt.sp.jedit.bsh.Name.invokeMethod(Name.java:855)
    at org.gjt.sp.jedit.bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
    at org.gjt.sp.jedit.bsh.BSHBlock.evalBlock(BSHBlock.java:130)
    at org.gjt.sp.jedit.bsh.BSHBlock.eval(BSHBlock.java:80)
    at org.gjt.sp.jedit.bsh.BshMethod.invokeImpl(BshMethod.java:362)
    at org.gjt.sp.jedit.bsh.BshMethod.invoke(BshMethod.java:258)
    at org.gjt.sp.jedit.bsh.BshMethod.invoke(BshMethod.java:186)
    at org.gjt.sp.jedit.bsh.Name.invokeLocalMethod(Name.java:914)
    at org.gjt.sp.jedit.bsh.Name.invokeMethod(Name.java:801)
    at org.gjt.sp.jedit.bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
    at org.gjt.sp.jedit.bsh.BSHIfStatement.eval(BSHIfStatement.java:51)
    at org.gjt.sp.jedit.bsh.Interpreter.eval(Interpreter.java:644)
    at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:339)
    at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:287)
    at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:213)
    at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.java:1151)
    at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:573)
    at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:342)
    at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:3386)
    at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:1)
    at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:212)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:374)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:829)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:873)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    at java.awt.Component.processMouseEvent(Component.java:6389)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3268)
    at java.awt.Component.processEvent(Component.java:6154)
    at java.awt.Container.processEvent(Container.java:2045)
    at java.awt.Component.dispatchEventImpl(Component.java:4750)
    at java.awt.Container.dispatchEventImpl(Container.java:2103)
    at java.awt.Component.dispatchEvent(Component.java:4576)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
    at java.awt.Container.dispatchEventImpl(Container.java:2089)
    at java.awt.Window.dispatchEventImpl(Window.java:2518)
    at java.awt.Component.dispatchEvent(Component.java:4576)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
    at java.awt.EventQueue.access$400(EventQueue.java:96)
    at java.awt.EventQueue$2.run(EventQueue.java:631)
    at java.awt.EventQueue$2.run(EventQueue.java:629)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
    at java.awt.EventQueue$3.run(EventQueue.java:645)
    at java.awt.EventQueue$3.run(EventQueue.java:643)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

     
  • Bao N. Nguyen
    Bao N. Nguyen
    2012-12-16

    Similar bug with Edit/Move Line Down

    java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2
    at org.gjt.sp.jedit.buffer.JEditBuffer.getLineStartOffset(JEditBuffer.java:358)
    at org.gjt.sp.jedit.textarea.TextArea.getLineStartOffset(TextArea.java:1265)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.gjt.sp.jedit.bsh.Reflect.invokeMethod(Reflect.java:134)
    at org.gjt.sp.jedit.bsh.Reflect.invokeObjectMethod(Reflect.java:80)
    at org.gjt.sp.jedit.bsh.Name.invokeMethod(Name.java:855)
    at org.gjt.sp.jedit.bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
    at org.gjt.sp.jedit.bsh.BSHArguments.getArguments(BSHArguments.java:65)
    at org.gjt.sp.jedit.bsh.BSHAllocationExpression.objectAllocation(BSHAllocationExpression.java:81)
    at org.gjt.sp.jedit.bsh.BSHAllocationExpression.eval(BSHAllocationExpression.java:62)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
    at org.gjt.sp.jedit.bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
    at org.gjt.sp.jedit.bsh.BSHAssignment.eval(BSHAssignment.java:77)
    at org.gjt.sp.jedit.bsh.BSHBlock.evalBlock(BSHBlock.java:130)
    at org.gjt.sp.jedit.bsh.BSHBlock.eval(BSHBlock.java:80)
    at org.gjt.sp.jedit.bsh.BSHBlock.eval(BSHBlock.java:46)
    at org.gjt.sp.jedit.bsh.BSHForStatement.eval(BSHForStatement.java:111)
    at org.gjt.sp.jedit.bsh.Interpreter.eval(Interpreter.java:644)
    at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:339)
    at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:287)
    at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:213)
    at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.java:1151)
    at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:573)
    at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:342)
    at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:3386)
    at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:1)
    at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:212)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:374)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:829)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:873)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    at java.awt.Component.processMouseEvent(Component.java:6389)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3268)
    at java.awt.Component.processEvent(Component.java:6154)
    at java.awt.Container.processEvent(Container.java:2045)
    at java.awt.Component.dispatchEventImpl(Component.java:4750)
    at java.awt.Container.dispatchEventImpl(Container.java:2103)
    at java.awt.Component.dispatchEvent(Component.java:4576)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
    at java.awt.Container.dispatchEventImpl(Container.java:2089)
    at java.awt.Window.dispatchEventImpl(Window.java:2518)
    at java.awt.Component.dispatchEvent(Component.java:4576)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
    at java.awt.EventQueue.access$400(EventQueue.java:96)
    at java.awt.EventQueue$2.run(EventQueue.java:631)
    at java.awt.EventQueue$2.run(EventQueue.java:629)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
    at java.awt.EventQueue$3.run(EventQueue.java:645)
    at java.awt.EventQueue$3.run(EventQueue.java:643)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

     
    • assigned_to: nobody --> kpouer
    • status: open --> closed-fixed
     
  • The macros cut and copy lines were fixed in trunk, the macros move lines up and down were rewritten