Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 63836

Summary: [implementation] ArrayIndexOutOfBoundsException in BufferedRuleBasedScanner
Product: [Eclipse Project] JDT Reporter: Nico Seessle <nico>
Component: TextAssignee: Christof Marti <christof_marti>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P2 CC: john.arthorne
Version: 3.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Nico Seessle CLA 2004-05-25 08:59:59 EDT
3.0M9

I can't reproduce this problem, but it occured, when I cut some code, paste it
in another place in the same class and pressed Ctrl+Shift+F to reformat the
code. After the error message the editor went grey and did not repaint. Closing
the editor correctly asked for saving the changes, and the changes were
correctly saved. After reopening the editor formatting does work normally.

I can not reproduce this problem.

Probably this description does not help you very much, but maybe there is a way
to handle the IOOB in a better way.

!ENTRY org.eclipse.ui 4 4 Mai 25, 2004 14:29:30.812
!MESSAGE The command for the key you pressed failed
!ENTRY org.eclipse.ui 4 0 Mai 25, 2004 14:29:30.812
!MESSAGE -5
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: -5
	at
org.eclipse.jface.text.rules.BufferedRuleBasedScanner.read(BufferedRuleBasedScanner.java:118)
	at
org.eclipse.jdt.internal.ui.text.java.JavaCodeScanner$OperatorRule.evaluate(JavaCodeScanner.java:81)
	at
org.eclipse.jface.text.rules.RuleBasedScanner.nextToken(RuleBasedScanner.java:155)
	at
org.eclipse.jdt.internal.ui.text.AbstractJavaScanner.nextToken(AbstractJavaScanner.java:115)
	at
org.eclipse.jface.text.rules.DefaultDamagerRepairer.createPresentation(DefaultDamagerRepairer.java:166)
	at
org.eclipse.jface.text.presentation.PresentationReconciler.createPresentation(PresentationReconciler.java:446)
	at
org.eclipse.jface.text.presentation.PresentationReconciler.processDamage(PresentationReconciler.java:555)
	at
org.eclipse.jface.text.presentation.PresentationReconciler.access$3(PresentationReconciler.java:553)
	at
org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.textChanged(PresentationReconciler.java:222)
	at org.eclipse.jface.text.TextViewer.updateTextListeners(TextViewer.java:2235)
	at org.eclipse.jface.text.TextViewer.fireRedrawChanged(TextViewer.java:4268)
	at org.eclipse.jface.text.TextViewer.disableRedrawing(TextViewer.java:4361)
	at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:4371)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:706)
	at
org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1098)
	at
org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:151)
	at
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:198)
	at
org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:122)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:120)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:881)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:141)
	at org.eclipse.ui.internal.commands.Command.execute(Command.java:132)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:469)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:887)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:928)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:546)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:494)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:259)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:712)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:795)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805)
	at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1724)
	at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1720)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3048)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:2951)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3282)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1475)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2380)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
	at org.eclipse.core.launcher.Main.run(Main.java:638)
	at org.eclipse.core.launcher.Main.main(Main.java:622)
Comment 1 Dani Megert CLA 2004-05-25 11:07:27 EDT
should investigate for 3.0
Comment 2 Andrew Freeman CLA 2004-05-27 13:14:46 EDT
I get this when I try to reformat the entire project:

!MESSAGE Internal Error
!STACK 0
java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run
(ProgressMonitorDialog.java:397)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run
(ProgressMonitorJobsDialog.java:238)
	at org.eclipse.ui.internal.progress.ProgressManager$3.run
(ProgressManager.java:778)
	at org.eclipse.swt.custom.BusyIndicator.showWhile
(BusyIndicator.java:69)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile
(ProgressManager.java:812)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile
(ProgressManager.java:787)
	at org.eclipse.ui.internal.progress.ProgressManager.run
(ProgressManager.java:968)
	at org.eclipse.jdt.ui.actions.FormatAllAction.runOnMultiple
(FormatAllAction.java:284)
	at org.eclipse.jdt.ui.actions.FormatAllAction.run
(FormatAllAction.java:269)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun
(SelectionDispatchAction.java:212)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run
(SelectionDispatchAction.java:188)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:881)
	at 
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:899)
	at org.eclipse.jface.action.ActionContributionItem.access$2
(ActionContributionItem.java:850)
	at org.eclipse.jface.action.ActionContributionItem$7.handleEvent
(ActionContributionItem.java:769)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench
(Workbench.java:253)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
	at org.eclipse.ui.internal.ide.IDEApplication.run
(IDEApplication.java:97)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run
(PlatformActivator.java:307)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:256)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:127)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
	at org.eclipse.core.launcher.Main.run(Main.java:638)
	at org.eclipse.core.launcher.Main.main(Main.java:622)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:326)
	at org.eclipse.jdt.internal.ui.text.comment.JavaDocRegion.formatRegion
(JavaDocRegion.java:133)
	at org.eclipse.jdt.internal.ui.text.comment.CommentRegion.format
(CommentRegion.java:218)
	at 
org.eclipse.jdt.internal.ui.text.comment.CommentFormattingStrategy.format
(CommentFormattingStrategy.java:145)
	at 
org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlave
(MultiPassContentFormatter.java:218)
	at 
org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlaves
(MultiPassContentFormatter.java:265)
	at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format
(MultiPassContentFormatter.java:141)
	at org.eclipse.jdt.ui.actions.FormatAllAction.doFormat
(FormatAllAction.java:321)
	at org.eclipse.jdt.ui.actions.FormatAllAction.formatCompilationUnit
(FormatAllAction.java:385)
	at org.eclipse.jdt.ui.actions.FormatAllAction.doRunOnMultiple
(FormatAllAction.java:358)
	at org.eclipse.jdt.ui.actions.FormatAllAction.access$0
(FormatAllAction.java:328)
	at org.eclipse.jdt.ui.actions.FormatAllAction$1.run
(FormatAllAction.java:286)
	at org.eclipse.jdt.internal.core.BatchOperation.executeOperation
(BatchOperation.java:34)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run
(JavaModelOperation.java:700)
	at org.eclipse.core.internal.resources.Workspace.run
(Workspace.java:1672)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3240)
	at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run
(WorkbenchRunnableAdapter.java:65)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run
(ModalContext.java:101)
Root exception:
java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:326)
	at org.eclipse.jdt.internal.ui.text.comment.JavaDocRegion.formatRegion
(JavaDocRegion.java:133)
	at org.eclipse.jdt.internal.ui.text.comment.CommentRegion.format
(CommentRegion.java:218)
	at 
org.eclipse.jdt.internal.ui.text.comment.CommentFormattingStrategy.format
(CommentFormattingStrategy.java:145)
	at 
org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlave
(MultiPassContentFormatter.java:218)
	at 
org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlaves
(MultiPassContentFormatter.java:265)
	at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format
(MultiPassContentFormatter.java:141)
	at org.eclipse.jdt.ui.actions.FormatAllAction.doFormat
(FormatAllAction.java:321)
	at org.eclipse.jdt.ui.actions.FormatAllAction.formatCompilationUnit
(FormatAllAction.java:385)
	at org.eclipse.jdt.ui.actions.FormatAllAction.doRunOnMultiple
(FormatAllAction.java:358)
	at org.eclipse.jdt.ui.actions.FormatAllAction.access$0
(FormatAllAction.java:328)
	at org.eclipse.jdt.ui.actions.FormatAllAction$1.run
(FormatAllAction.java:286)
	at org.eclipse.jdt.internal.core.BatchOperation.executeOperation
(BatchOperation.java:34)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run
(JavaModelOperation.java:700)
	at org.eclipse.core.internal.resources.Workspace.run
(Workspace.java:1672)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3240)
	at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run
(WorkbenchRunnableAdapter.java:65)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run
(ModalContext.java:101)
Comment 3 Dani Megert CLA 2004-05-27 13:55:13 EDT

*** This bug has been marked as a duplicate of 57011 ***
Comment 4 Christof Marti CLA 2004-06-03 05:27:57 EDT
The exception from comment 2 is covered by bug 57011. The exception from comment
0 is not.
Comment 5 Christof Marti CLA 2004-06-03 05:30:46 EDT
*** Bug 64162 has been marked as a duplicate of this bug. ***
Comment 6 Christof Marti CLA 2004-06-16 04:11:02 EDT
Duplicate has same stack trace, but happend without formatting. Adapting summary
to reflect this.

The implementation in this area has been rearranged slightly since M9.
Comment 7 Christof Marti CLA 2004-06-16 09:18:48 EDT
PresentationReconciler.processDamage(..) should never have been called. Fix went
into 3.0RC2.
Comment 8 Dani Megert CLA 2004-06-16 14:49:20 EDT
probably not fixed
Comment 9 Dani Megert CLA 2004-06-16 14:50:08 EDT

*** This bug has been marked as a duplicate of 67428 ***