Bug 120902 - Member.getJavadocRange() causes AIOOBE
Summary: Member.getJavadocRange() causes AIOOBE
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-14 11:45 EST by Dani Megert CLA
Modified: 2005-12-14 19:35 EST (History)
0 users

See Also:


Attachments
Proposed fix (1.16 KB, patch)
2005-12-14 12:11 EST, Olivier Thomann CLA
no flags Details | Diff
Regression test (1.40 KB, patch)
2005-12-14 12:20 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2005-12-14 11:45:52 EST
I20051214-0800

1. create a CU like this:
/**
 * Toy
 */
public class Toy {
	// copy line (Ctrl+Alt+Arrow_Down
}

2. copy the single line comment several times (let's say 10x)
3. select from the last single line comment to just after Toy in the Javadoc
4. now quickly press Backspace and Ctrl+Space
==> AIOOBE (see below)

This happens because the model is not yet reconciled but access the already changed buffer with invalid offset/length.

!ENTRY org.eclipse.ui 4 0 2005-12-14 17:42:01.434
!MESSAGE Failed to execute runnable (java.lang.ArrayIndexOutOfBoundsException)
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ArrayIndexOutOfBoundsException)
	at org.eclipse.swt.SWT.error(SWT.java:3283)
	at org.eclipse.swt.SWT.error(SWT.java:3206)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3218)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2864)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1762)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1726)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:397)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:109)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	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.invokeFramework(Main.java:338)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.lang.ArrayIndexOutOfBoundsException
	at org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter.getText(DocumentAdapter.java:317)
	at org.eclipse.jdt.internal.core.Member.getJavadocRange(Member.java:261)
	at org.eclipse.jdt.ui.JavadocContentAccess.getContentReader(JavadocContentAccess.java:59)
	at org.eclipse.jdt.ui.JavadocContentAccess.getHTMLContentReader(JavadocContentAccess.java:117)
	at org.eclipse.jdt.internal.ui.text.java.MemberProposalInfo.extractJavadoc(MemberProposalInfo.java:102)
	at org.eclipse.jdt.internal.ui.text.java.MemberProposalInfo.computeInfo(MemberProposalInfo.java:81)
	at org.eclipse.jdt.internal.ui.text.java.MemberProposalInfo.getInfo(MemberProposalInfo.java:68)
	at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getAdditionalProposalInfo(LazyJavaCompletionProposal.java:180)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation(AdditionalInfoController.java:221)
	at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:820)
	at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:810)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run(AdditionalInfoController.java:173)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
	... 20 more
Comment 1 Frederic Fusier CLA 2005-12-14 12:08:49 EST
I never succeeded to get this AIOOBE strictly following your scenario...
I tried with a small example as suggested and also with our biggest CU (Parser.java) to have long time for reconciling.
I even launched a full build of my workspace to slow my box but never got it...
Are you able to reproduce easily? How fast should I need to be between step 3 and 4?
Comment 2 Frederic Fusier CLA 2005-12-14 12:09:11 EST
I guess this is with 3.2...
Comment 3 Olivier Thomann CLA 2005-12-14 12:10:22 EST
The member needs to check if the compilation is consistent before returning the javadoc range.
I am working on a fix.
Would null be acceptable in this case?
Comment 4 Olivier Thomann CLA 2005-12-14 12:11:31 EST
Created attachment 31757 [details]
Proposed fix

Dani, could you please give it a try?
Comment 5 Olivier Thomann CLA 2005-12-14 12:20:10 EST
Created attachment 31758 [details]
Regression test
Comment 6 Olivier Thomann CLA 2005-12-14 12:37:25 EST
Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.model.CompilationUnitTests.test120902
Comment 7 Dani Megert CLA 2005-12-14 13:31:28 EST
Applied patch on HEAD of JDT Core and it works for me. Thanks.
Comment 8 Olivier Thomann CLA 2005-12-14 19:35:59 EST
Verified with I20051214-1600 for 3.2M4