Bug 223878 - [content assist] Illegal argument exception from content assist
Summary: [content assist] Illegal argument exception from content assist
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.4 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 223936 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-25 12:01 EDT by Samantha Chan CLA
Modified: 2008-03-28 05:14 EDT (History)
6 users (show)

See Also:


Attachments
Proposed fix (10.42 KB, patch)
2008-03-27 10:16 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 Samantha Chan CLA 2008-03-25 12:01:29 EDT
1.  Stop at the breakpoint
2.  From the variables view, select list
3.  From the details pane, type "this." and then CTRL+Space to invoke content assist.
4.  Blows up with an error in Error Log.

Testcase:
	public List autoboxing(int[] array){
		List<Integer> list = new ArrayList();
		for(int i: array){
			list.add(i);
		}
		list.add(1);
		list.add(Integer.MAX_VALUE);
		list.add(Integer.MIN_VALUE);
		return list;  // BREAKPOINT HERE
	}

Exception:

java.lang.IllegalArgumentException
	at org.eclipse.jdt.internal.core.util.Util.scanTypeSignature(Util.java:2631)
	at org.eclipse.jdt.internal.core.util.Util.scanTypeArgumentSignature(Util.java:2960)
	at org.eclipse.jdt.internal.core.util.Util.scanTypeArgumentSignatures(Util.java:2924)
	at org.eclipse.jdt.internal.core.util.Util.scanClassTypeSignature(Util.java:2823)
	at org.eclipse.jdt.internal.core.util.Util.scanTypeSignature(Util.java:2611)
	at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1644)
	at org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider.createMethodProposalLabel(CompletionProposalLabelProvider.java:268)
	at org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider.createStyledLabel(CompletionProposalLabelProvider.java:534)
	at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.computeDisplayString(LazyJavaCompletionProposal.java:241)
	at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getDisplayString(LazyJavaCompletionProposal.java:226)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.handleSetData(CompletionProposalPopup.java:797)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$24(CompletionProposalPopup.java:783)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$3.handleEvent(CompletionProposalPopup.java:576)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:83)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1026)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1011)
	at org.eclipse.swt.widgets.Table.checkData(Table.java:900)
	at org.eclipse.swt.widgets.Table.wmNotifyChild(Table.java:6092)
	at org.eclipse.swt.widgets.Control.wmNotify(Control.java:4707)
	at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:1761)
	at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:4337)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3830)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:334)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1555)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1909)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4486)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2250)
	at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:317)
	at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:192)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3866)
	at org.eclipse.swt.widgets.Table.windowProc(Table.java:5301)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4486)
	at org.eclipse.swt.internal.win32.OS.UpdateWindow(Native Method)
	at org.eclipse.swt.widgets.Decorations.setVisible(Decorations.java:1368)
	at org.eclipse.swt.widgets.Shell.setVisible(Shell.java:1755)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.displayProposals(CompletionProposalPopup.java:1139)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$23(CompletionProposalPopup.java:1104)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:493)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:475)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1645)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:791)
	at org.eclipse.ui.console.actions.TextViewerAction.run(TextViewerAction.java:68)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:119)
	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:83)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1160)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1001)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1026)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1011)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1039)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1035)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1351)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3883)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:338)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3776)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:334)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4473)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2336)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3370)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2368)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2332)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:476)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:471)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	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:362)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:612)
	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)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Comment 1 Samantha Chan CLA 2008-03-25 12:07:29 EDT
Only received exception for a certain types of objects.  It was also problematic if the type of object is an array, e.g. String[]
Comment 2 Darin Wright CLA 2008-03-25 12:28:17 EDT
Moving to JDT text for investigation.
Comment 3 Dani Megert CLA 2008-03-25 12:40:06 EDT
Need to investigate for M6 but most likely not a regression.
Comment 4 Darin Wright CLA 2008-03-25 14:38:51 EDT
*** Bug 223936 has been marked as a duplicate of this bug. ***
Comment 5 Dani Megert CLA 2008-03-26 14:09:30 EDT
This looks like a bug in JDT Core: we call this:

char[] name= fProposal.getName();
char[] parameterList= Signature.toCharArray(fProposal.getSignature(), null, null, 
                                               false, false);

Where fPropsal is a CompletionProposal returned by JDT Core.
Comment 6 Dani Megert CLA 2008-03-26 14:11:14 EDT
Note that Signature.toCharArray(...) does not specify to throw any exception. Maybe something is already wrong with the returned proposal?
Comment 7 Dani Megert CLA 2008-03-26 14:12:34 EDT
Here's a complete snippet as the one from comment 0 isn't really ready to go:

package snippet;

import java.util.ArrayList;
import java.util.List;

public class Snippet {
	public static void main(String[] args) {
		Snippet s= new Snippet();
		s.autoboxing(new int[] {1, 2, 3});
	}
	public List autoboxing(int[] array){
	        List<Integer> list = new ArrayList();
	        for(int i: array){
	                list.add(i);
	        }
	        list.add(1);
	        list.add(Integer.MAX_VALUE);
	        list.add(Integer.MIN_VALUE);
	        return list;  // BREAKPOINT HERE
	}
	
}

Comment 8 Dani Megert CLA 2008-03-26 14:13:39 EDT
Removing target milestone as this is up to JDT Core to decide but should at least check whether this is a regression compared to M5.
Comment 9 Olivier Thomann CLA 2008-03-26 14:25:15 EDT
This is a regression from 3.4M5.
Comment 10 Olivier Thomann CLA 2008-03-26 15:22:12 EDT
The illegalArgumentException is thrown trying to parse:
[(, I, L, j, a, v, a, ., u, t, i, l, ., C, o, l, l, e, c, t, i, o, n, <, ?,  , e, x, t, e, n, d, s,  , E, >, ;, ), Z]

So the signature is wrong.
Comment 11 David Audel CLA 2008-03-27 09:54:01 EDT
This problem is caused by the bug 133005.

The BinaryTypeConverter build a type reference with the name 'Collection<? extends E)'.
Before 3.4M5 the type resolution failed with this broken type reference but it doesn't fail with the support for missing types added in 3.4M6.

For 3.4M6 I investigate a fix to filter in BinaryTypeConverter all methods and fields which contain a parameterized reference. The behavior will be the same as M5 and will avoid the IllegalArgumentException.
I will fix the bug 133005 in 3.4M7.
Comment 12 David Audel CLA 2008-03-27 10:16:29 EDT
Created attachment 93802 [details]
Proposed fix
Comment 13 David Audel CLA 2008-03-27 10:25:26 EDT
Released for 3.4M6.

Test added
  SnippetCompletionTests_1_5#testCodeSnippetAssistForBug223878()
Comment 14 Frederic Fusier CLA 2008-03-28 05:14:23 EDT
Verified for 3.4M6 using I20080327-2251.