Bug 243023 - [content assist] RuntimeException thrown by JavaTypeCompletionProposalComputer
Summary: [content assist] RuntimeException thrown by JavaTypeCompletionProposalComputer
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-04 02:38 EDT by Gunnar Wagenknecht CLA
Modified: 2008-09-16 04:25 EDT (History)
2 users (show)

See Also:


Attachments
Test project for reproducing (1.46 KB, application/x-zip-compressed)
2008-08-04 02:53 EDT, Gunnar Wagenknecht CLA
no flags Details
Proposed fix (2.55 KB, patch)
2008-09-04 09:06 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2008-08-04 02:38:24 EDT
eclipse.buildId=I20080617-2000
java.version=1.6.0_07
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments:  -os win32 -ws win32 -arch x86


Warning
Mon Aug 04 08:35:21 CEST 2008
The 'org.eclipse.jdt.ui.JavaTypeCompletionProposalComputer' proposal computer from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The extension has thrown a runtime exception.

java.lang.IllegalArgumentException
at org.eclipse.jdt.core.Signature.appendTypeSignature(Signature.java:2371)
at org.eclipse.jdt.core.Signature.appendTypeSignature(Signature.java:2278)
at org.eclipse.jdt.core.Signature.toCharArray(Signature.java:2257)
at org.eclipse.jdt.core.Signature.toString(Signature.java:2734)
at org.eclipse.jdt.internal.corext.template.java.SignatureUtil.stripSignatureToFQN(SignatureUtil.java:201)
at org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext.getExpectedType(JavaContentAssistInvocationContext.java:218)
at org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposalComputer.computeCompletionProposals(JavaTypeCompletionProposalComputer.java:63)
at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:316)
at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:264)
at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:285)
at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:245)
at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1836)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:553)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:550)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$14.run(CompletionProposalPopup.java:1538)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.incrementalComplete(CompletionProposalPopup.java:1532)
at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1663)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:177)
at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:471)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:822)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:511)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1184)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894)
at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:341)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2370)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
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:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
Comment 1 Gunnar Wagenknecht CLA 2008-08-04 02:43:48 EDT
Unfortunately, this happens occasionally. I didn't find a way to reproduce it. I tried a fresh workspace but it didn't work. 

The type in question had compile errors, though. It was similar to this one:
---
package test;

import java.util.Dictionary;

public abstract class Test {

	private final String id;

	protected Test(final String id) {
		if (null == [INVOKED_CODE_COMPLETE_HERE]) {
			this.id = id;
		}
	}

	public abstract Object newInstance(String id, Dictionary<String, String> properties);

	public boolean validateId(final String repositoryId) {
		return true;
	}
}
---

However, I couldn't reproduce it useing the code above in a fresh workspace.
Comment 2 Gunnar Wagenknecht CLA 2008-08-04 02:53:28 EDT
Created attachment 109042 [details]
Test project for reproducing

Ok, I think I found a test case. Import the attached test project and open Test.java. Follow the instructions in the comment inside the constructor
Comment 3 Dani Megert CLA 2008-08-04 03:44:48 EDT
Simpler test case:

public  class Test {
	public void foo() {
		if (null== //<-- code assist before comment
	}
}

Comment 4 Dani Megert CLA 2008-08-04 04:11:26 EDT
This bug got introduced in 3.4. Might be a 3.4.1 candidate.
Comment 5 Dani Megert CLA 2008-08-04 04:15:17 EDT
org.eclipse.jdt.core.CompletionContext.getExpectedTypesSignatures() returns [[N]]. This seems wrong.

In 3.3.2 JDT Core returned: [[S], [I], [J], [F], [D], [C], [B]]
Comment 6 David Audel CLA 2008-09-04 09:06:27 EDT
Created attachment 111667 [details]
Proposed fix
Comment 7 David Audel CLA 2008-09-04 09:13:00 EDT
Released for 3.5M2.

Test added
  CompletionContextTests#test0166()

getExpectedTypesSignatures() will return no expected type in this case.
Comment 8 Jerome Lanneluc CLA 2008-09-16 04:25:31 EDT
Verified for 3.5M2 using I20080914-2000