Bug 127241 - SIOOBE in StubUtility.hasConstantName during quick fix
Summary: SIOOBE in StubUtility.hasConstantName during quick fix
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-10 05:14 EST by Dani Megert CLA
Modified: 2006-03-28 10:02 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2006-02-10 05:14:58 EST
I20060208-0824 + plug-in export (imported JCore from it)

class B  {
	void foo() {
		new Ä().f;<quick fix here>
	}
}


!ENTRY org.eclipse.jdt.ui 4 4 2006-02-10 11:11:42.920
!MESSAGE An error occurred while computing quick fixes. Check log for details.
!SUBENTRY 1 org.eclipse.jdt.ui 4 0 2006-02-10 11:11:42.920
!MESSAGE Exception while processing quick fixes or quick assists
!SUBENTRY 2 org.eclipse.jdt.ui 4 4 2006-02-10 11:11:42.920
!MESSAGE Exception while processing quick fixes or quick assists
!STACK 0
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.lang.String.charAt(String.java:558)
	at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility.hasConstantName(StubUtility.java:939)
	at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.addNewFieldForType(UnresolvedElementsSubProcessor.java:336)
	at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.addNewFieldProposals(UnresolvedElementsSubProcessor.java:294)
	at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getVariableProposals(UnresolvedElementsSubProcessor.java:233)
	at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:262)
	at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:218)
	at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:336)
	at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:301)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:815)
	at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:291)
	at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:418)
	at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectProposals(JavaCorrectionProcessor.java:242)
	at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.computeCompletionProposals(JavaCorrectionProcessor.java:205)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1568)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:447)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$15(CompletionProposalPopup.java:444)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:379)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:373)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1417)
	at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant.showPossibleCompletions(JavaCorrectionAssistant.java:173)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:763)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1519)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:177)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:200)
	at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:492)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:389)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:421)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:160)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:466)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:798)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:845)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:563)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:506)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:122)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:978)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:924)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:949)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:934)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:962)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:958)
	at org.eclipse.swt.widgets.Widget.wmKeyDown(Widget.java:1557)
	at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:3556)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3264)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3965)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1799)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2905)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1793)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1757)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:402)
	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:374)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169)
	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:585)
	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)
Comment 1 Martin Aeschlimann CLA 2006-02-12 12:10:04 EST
The problem is the statement recovery: It creates a SimpleName with length 0. This is not valid and our code is not prepared for this. I also filed bug 127395 so this is detected earlier.

In this case it seems unessesary to introduce a assignment statement. Just put the field in a ExpressionStatement.

ExpressionStatement [60, 10] (recovered)
	EXPRESSION
		Assignment [60, 9] (recovered)
			LEFT_HAND_SIDE
				FieldAccess [60, 9]
			OPERATOR: '='
			RIGHT_HAND_SIDE
				SimpleName [68, 1] (recovered)
					IDENTIFIER: ''
Comment 2 Philipe Mulet CLA 2006-02-13 04:28:29 EST
If the added nodes are tagged as recovered, then this should still be supported. Maybe not ideal, or what you'd been expecting, but still legite.

What about the case where you'd have:

class B  {
        void foo() {
                new Ä(). <quick fix here>
        }
}

Here an empty name is likely introduced again.
Comment 3 David Audel CLA 2006-02-27 12:25:46 EST
Fixed and test updated (see bug 127395 comment 5)
Comment 4 Olivier Thomann CLA 2006-03-28 10:02:01 EST
Verified using I20060328-0010 for 3.2M6