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

Bug 367432

Summary: Index out of bounds exception inside the Java editor
Product: [Eclipse Project] Platform Reporter: Olivier Thomann <Olivier_Thomann>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, deepakazad, remy.suen
Version: 4.1Keywords: needinfo
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Java project to import
none
Source code to open in an external text editor none

Description Olivier Thomann CLA 2011-12-22 10:49:58 EST
Created attachment 208738 [details]
Java project to import

Using eclipse.buildId=I20111205-1315
java.version=1.6.0_31-ea
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_CA
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -console,

org.eclipse.jface.text.BadLocationException
	at org.eclipse.jface.text.AbstractDocument.addPosition(AbstractDocument.java:355)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.addPosition(SynchronizableDocument.java:236)
	at org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingPresenter.updatePresentation(SemanticHighlightingPresenter.java:414)
	at org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingPresenter$1.run(SemanticHighlightingPresenter.java:347)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:977)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:893)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:91)
	at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:565)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:520)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:352)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:624)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:579)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1433)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1409)

Caused by: java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4281)
	at org.eclipse.swt.SWT.error(SWT.java:4215)
	at org.eclipse.swt.SWT.error(SWT.java:4186)
	at org.eclipse.swt.custom.StyledText.setStyleRanges(StyledText.java:9693)
	at org.eclipse.swt.custom.StyledText.replaceStyleRanges(StyledText.java:7729)
	at org.eclipse.jface.text.TextViewer.addPresentation(TextViewer.java:4817)
	at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4896)
	at org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingPresenter.updatePresentation(SemanticHighlightingPresenter.java:448)
	at org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingPresenter$1.run(SemanticHighlightingPresenter.java:347)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	... 24 more

I got this exception after I did a copy/paste from a file that contains some source. On the selection of the code, I am getting the exception.

Steps to reproduce:
1) Import the attached java project
2) Open the attached source file into an external text editor
3) Select the whole class and copy.
4) Select the project's source folder and paste
5) Open the editor is opened, format the code using Ctrl + Shift + F.
6) Select the whole code using Ctrl + A
7) Move the mouse over the selection
8) You should get both exceptions reported above.
Comment 1 Olivier Thomann CLA 2011-12-22 10:50:38 EST
Created attachment 208739 [details]
Source code to open in an external text editor
Comment 2 Olivier Thomann CLA 2011-12-22 10:51:19 EST
Let me know if you cannot reproduce. I reproduce reliably in my workspace.
Comment 3 Deepak Azad CLA 2011-12-22 15:50:47 EST
I am unable to reproduce this. Also I don't see anything special in the source which is copied.

(In reply to comment #0)
> 5) Open the editor is opened, format the code using Ctrl + Shift + F.
Olivier, is formatting the code important to reproduce the problem? Is there something special in the formatter profile?
Comment 4 Dani Megert CLA 2012-01-05 09:00:20 EST
(In reply to comment #3)
> I am unable to reproduce this.

Same here on 3.8 and 4.2. Olivier, can you reproduce in a new workspace using http://download.eclipse.org/eclipse/downloads/drops/I20120103-0800/index.php or http://download.eclipse.org/eclipse/downloads/drops4/I20120103-1230/index.php?
Comment 5 Dani Megert CLA 2012-01-09 05:41:36 EST
Ping!
Comment 6 Olivier Thomann CLA 2012-01-09 12:03:51 EST
I had issues with my workspace last week. I'll try to find some time to test it this week. Sorry for the delay.
Comment 7 Olivier Thomann CLA 2012-01-12 11:25:21 EST
I can no longer reproduce this issue. Ok to close as WORKSFORME. I'll reopen if I can provide more information to reproduce it.
Comment 8 Dani Megert CLA 2012-01-12 11:28:10 EST
(In reply to comment #7)
> I can no longer reproduce this issue. Ok to close as WORKSFORME. I'll reopen if
> I can provide more information to reproduce it.

Thanks for the update Olivier.