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

Bug 318697

Summary: IllegalArgumentException in Util.scanTypeSignature(char[], int) line: 2240
Product: [WebTools] JSDT Reporter: Jacek Pospychala <jacek.pospychala>
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: RESOLVED WORKSFORME QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: cmjaun
Version: 3.2Keywords: needinfo
Target Milestone: 3.2.2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
patch none

Description Jacek Pospychala CLA 2010-07-02 07:18:47 EDT
With sample js file like this:


/**
 * @constructor
 */
Obj = function() {
};

/**
 * @return boolean
 */
Obj.isFunction = function(obj) {
	return ;
};

Obj.|  <---- press Ctrl+Space


An exception is thrown:

Daemon Thread [Thread-0] (Suspended (exception IllegalArgumentException))	
	Util.scanTypeSignature(char[], int) line: 2240	
	Signature.getReturnType(char[]) line: 813	
	CompletionProposalLabelProvider.createMethodProposalLabel(CompletionProposal) line: 246	
	CompletionProposalLabelProvider.createLabel(CompletionProposal) line: 529	
	FilledArgumentNamesMethodProposal(LazyJavaCompletionProposal).computeDisplayString() line: 222	
	FilledArgumentNamesMethodProposal(LazyJavaCompletionProposal).getDisplayString() line: 212	
	FilledArgumentNamesMethodProposal(AbstractJavaCompletionProposal).isValidPrefix(String) line: 702	
	FilledArgumentNamesMethodProposal(LazyJavaCompletionProposal).isValidPrefix(String) line: 335	
	FilledArgumentNamesMethodProposal(JavaMethodCompletionProposal).isValidPrefix(String) line: 205	
	FilledArgumentNamesMethodProposal(AbstractJavaCompletionProposal).validate(IDocument, int, DocumentEvent) line: 669	
	FilledArgumentNamesMethodProposal(AbstractJavaCompletionProposal).apply(ITextViewer, char, int, int) line: 423	
	CompletionProposalPopup.insertProposal(ICompletionProposal, char, int, int) line: 928	
	CompletionProposalPopup.access$21(CompletionProposalPopup, ICompletionProposal, char, int, int) line: 892	
	CompletionProposalPopup$2.run() line: 495	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	CompletionProposalPopup.showProposals(boolean) line: 482	
	ContentAssistant.showPossibleCompletions() line: 1660	
	CompilationUnitEditor$AdaptedSourceViewer.doOperation(int) line: 168	
	ContentAssistAction$1.run() line: 82	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	ContentAssistAction.run() line: 80	
	ContentAssistAction(Action).runWithEvent(Event) line: 498	
	ActionHandler.execute(Map) line: 185	
	LegacyHandlerWrapper.execute(ExecutionEvent) line: 109	
	Command.executeWithChecks(ExecutionEvent) line: 476	
	ParameterizedCommand.executeWithChecks(Object, Object) line: 508	
	HandlerService.executeCommand(ParameterizedCommand, Event) line: 169	
	WorkbenchKeyboard.executeCommand(Binding, Event) line: 468	
	WorkbenchKeyboard.press(List, Event) line: 786	
	WorkbenchKeyboard.processKeyEvent(List, Event) line: 885	
	WorkbenchKeyboard.filterKeySequenceBindings(Event) line: 567	
	WorkbenchKeyboard.access$3(WorkbenchKeyboard, Event) line: 508	
	WorkbenchKeyboard$KeyDownFilter.handleEvent(Event) line: 123	
	EventTable.sendEvent(Event) line: 84	
	Display.filterEvent(Event) line: 1031	
	Display.sendEvent(EventTable, Event) line: 3775	
	StyledText(Widget).sendEvent(Event) line: 1367	
	StyledText(Widget).sendEvent(int, Event, boolean) line: 1390	
	StyledText(Widget).sendEvent(int, Event) line: 1375	
	StyledText(Widget).sendKeyEvent(int, Event) line: 1404	
	StyledText(Widget).sendKeyEvent(NSEvent, int) line: 1400	
	StyledText(Canvas).sendKeyEvent(NSEvent, int) line: 416	
	StyledText(Control).doCommandBySelector(int, int, int) line: 939	
	Display.windowProc(int, int, int) line: 5068	
	OS.objc_msgSend(int, int, int) line: not available [native method]	
	SWTCanvasView(NSResponder).interpretKeyEvents(NSArray) line: 56	
	StyledText(Composite).keyDown(int, int, int) line: 587	
	Display.windowProc(int, int, int) line: 4978	
	OS.objc_msgSendSuper(objc_super, int, int) line: not available [native method]	
	Shell(Widget).callSuper(int, int, int) line: 220	
	Shell(Widget).windowSendEvent(int, int, int) line: 1943	
	Shell.windowSendEvent(int, int, int) line: 2008	
	Display.windowProc(int, int, int) line: 5040	
	OS.objc_msgSendSuper(objc_super, int, int) line: not available [native method]	
	Display.applicationSendEvent(int, int, int) line: 4582	
	Display.applicationProc(int, int, int) line: 4659	
	OS.objc_msgSend(int, int, int) line: not available [native method]	
	NSApplication.sendEvent(NSEvent) line: 115	
	Display.readAndDispatch() line: 3274	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2629	
	Workbench.runUI() line: 2593	
	Workbench.access$4(Workbench) line: 2427	
	Workbench$7.run() line: 670	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 663	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 115	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 369	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	Main.invokeFramework(String[], URL[]) line: 619	
	Main.basicRun(String[]) line: 574	
	Main.run(String[]) line: 1407	
	Main.main(String[]) line: 1383
Comment 1 Jacek Pospychala CLA 2010-07-02 07:34:27 EDT
The problem is with parsing signature. isFunction method has signature "(A)Z". So it accepts 1 unspecified argument ("(A)") and returns boolean (Z).

When parsing the return type, in org.eclipse.wst.jsdt.internal.core.util.Util.scanTypeSignature(char[], int), there's a switch statement expecting the return type ('Z' in this case) to be one of:
[ - Array
L - Resolved
Q - Unresolved
V - Void
A - Any

Nothing matches, hence IAE.


The type parsing in Util.scanTypeSignature(char[], int) is not quite clear to me, because if the char is matching 'A'/ANY, then another method is invoked - Util.scanBaseTypeSignature(char[], int) to check the same char against "BCDFIJSVZA".indexOf(c). Probably it should be the other way around.
Comment 2 Jacek Pospychala CLA 2010-07-02 07:55:25 EDT
btw. I wouldn't notice this issue, if it won't cause Eclipse crashing on Linux. For some reason an exception thrown in display thread like here, ends with crash. On Windows or Mac not.
Comment 3 Jacek Pospychala CLA 2010-07-02 07:59:07 EDT
(In reply to comment #2)
> btw. I wouldn't notice this issue, if it won't cause Eclipse crashing on Linux.
> For some reason an exception thrown in display thread like here, ends with
> crash. On Windows or Mac not.

seems related to bug 285749
Comment 4 Jacek Pospychala CLA 2010-07-02 09:25:19 EDT
Created attachment 173304 [details]
patch

possible patch
Comment 5 Chris Jaun CLA 2010-07-02 10:06:13 EDT
Are you testing with the latest 3.2.1 contents?

I thought we had fixed something similar to this already.
Comment 6 Jacek Pospychala CLA 2010-07-02 17:54:38 EDT
I'm using HEAD.
The other similar bug I know was bug 314224 "function with @param {boolean} in jsdoc missing in content assist", but that was something else.
Comment 7 Chris Jaun CLA 2010-07-06 10:05:23 EDT
3.2.1 contents haven't been pulled up to HEAD yet...we probably will do that this week.
Comment 8 Nitin Dahyabhai CLA 2010-08-24 12:58:12 EDT
So is this something we still need to fix, or is it already fixed?
Comment 9 Chris Jaun CLA 2010-08-24 15:19:35 EDT
I can't reproduce this problem in 3.2.2.

As I said in Comment #5 I think we fixed this problem back in 3.2.1.

Jacek, if you can reproduce in the latest 3.2.2 code please re-open.