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

Bug 401080

Summary: Content assist fails to propose methods
Product: [Eclipse Project] JDT Reporter: Stefan Holzknecht <s.holzknecht>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: anchakrk, daniel_megert, jarthana, Olivier_Thomann, stephan.herrmann
Version: 4.3   
Target Milestone: 4.7 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Stefan Holzknecht CLA 2013-02-18 07:42:38 EST
The content assist fails due to an exception under some circumstances.
This might happen if you have e.g. the following two interfaces:

public interface ParameterKey<T>
{
    String getID();
    ParameterValueRange<? super T> getValueRange();
    T getDefaultValue();
}


public interface ParameterValueRange<T>
{
    Class<T> getType();
    ParameterValueValidator<? super T> getValidator();
}

If you request content assistance for the getType() method the content assistant fails due to an IllegalArgumentException.  

ParameterKey<?> x;
x.getValueRange().getType()

This seams to be related to the usage of <? super T>.

Following exception is logged:
!ENTRY org.eclipse.ui 4 0 2013-02-18 11:49:55.772
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalArgumentException)
             at org.eclipse.swt.SWT.error(SWT.java:4361)
             at org.eclipse.swt.SWT.error(SWT.java:4276)
             at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
             at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
             at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
             at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029)
             at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
             at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923)
             at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
             at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
             at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
             at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
             at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
             at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
             at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
             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:353)
             at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
             at java.lang.reflect.Method.invoke(Method.java:601)
             at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
             at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
             at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: java.lang.IllegalArgumentException
             at org.eclipse.jdt.internal.compiler.util.Util.scanTypeBoundSignature(Util.java:1456)
             at org.eclipse.jdt.internal.compiler.util.Util.scanTypeSignature(Util.java:1225)
             at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1769)
             at org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider.createMethodProposalLabel(CompletionProposalLabelProvider.java:278)
             at org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider.createStyledLabel(CompletionProposalLabelProvider.java:570)
             at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.computeDisplayString(LazyJavaCompletionProposal.java:262)
             at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getStyledDisplayString(LazyJavaCompletionProposal.java:238)
             at org.eclipse.jface.text.contentassist.CompletionProposalPopup.handleSetData(CompletionProposalPopup.java:841)
             at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$24(CompletionProposalPopup.java:831)
             at org.eclipse.jface.text.contentassist.CompletionProposalPopup$3.handleEvent(CompletionProposalPopup.java:593)
             at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
             at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
             at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
             at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
             at org.eclipse.swt.widgets.Table.checkData(Table.java:1166)
             at org.eclipse.swt.widgets.Table.wmNotifyChild(Table.java:6749)
             at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5534)
             at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:1896)
             at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5086)
             at org.eclipse.swt.widgets.Control.windowProc(Control.java:4584)
             at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
             at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1627)
             at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2069)
             at org.eclipse.swt.widgets.Display.windowProc(Display.java:4989)
             at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
             at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2440)
             at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:564)
             at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:430)
             at org.eclipse.swt.widgets.Control.windowProc(Control.java:4623)
             at org.eclipse.swt.widgets.Table.windowProc(Table.java:5913)
             at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
             at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
             at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2440)
             at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:564)
             at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:430)
             at org.eclipse.swt.widgets.Control.windowProc(Control.java:4623)
             at org.eclipse.swt.widgets.Table.windowProc(Table.java:5913)
             at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
             at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
             at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2440)
             at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:564)
             at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:430)
             at org.eclipse.swt.widgets.Control.windowProc(Control.java:4623)
             at org.eclipse.swt.widgets.Table.windowProc(Table.java:5913)
             at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
             at org.eclipse.swt.internal.win32.OS.SendMessageW(Native Method)
             at org.eclipse.swt.internal.win32.OS.SendMessage(OS.java:3290)
             at org.eclipse.swt.widgets.Table.setItemCount(Table.java:4645)
             at org.eclipse.jface.text.contentassist.CompletionProposalPopup.setProposals(CompletionProposalPopup.java:1127)
             at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7(CompletionProposalPopup.java:1105)
             at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:509)
             at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
             at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:492)
             at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:378)
             at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
             at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
             ... 23 more
Comment 1 Dani Megert CLA 2013-02-18 10:19:59 EST
Simpler test case:

public interface ParameterKey<T> {
	ParameterValueRange<? super T> getValueRange();
}

interface ParameterValueRange<T> {
	Class<T> getType();
}

class C {
	public void main(String[] args) {
		ParameterKey<?> x;
		x.getValueRange().getType().<content assist here>
	}
}
Comment 2 Dani Megert CLA 2013-02-18 10:27:10 EST
Jay, the IAE might be correct if JDT UI passes a wrong signature. In that case, please move back.
Comment 3 Jay Arthanareeswaran CLA 2013-02-18 23:08:12 EST
Anirban, can you please investigate and see if it's indeed a problem on JDT/Core side? Thanks!
Comment 4 ANIRBAN CHAKRABORTY CLA 2013-02-22 01:27:12 EST
Hello,
as per my investigation, the bounding box is not getting generated correctly, and hence the error routine is called.

More specifically:
the rectangle that is getting generated has attributes (in my testcase run)
height = 20
width = 234
x = 0
y = 0
[in method Styledtext::getOffsetAtPoint]

When it is checked against 'if (inTextOnly && !(rect.x  <= x && x <=  rect.x + rect.width))' it is generating '-1' which in turn is calling error routine 'SWT.error(SWT.ERROR_INVALID_ARGUMENT)' [in method StyledText::getOffsetAtLocation]

Thus, this seems to be a GUI issue.

Thanks
Anirban
Comment 5 Jay Arthanareeswaran CLA 2013-02-25 12:07:36 EST
This is the signature passed to the Signature util:

(Ljava.lang.Object;)-*

Doesn't appear in the format the code is expecting.

Dani, what do you think?
Comment 6 Jay Arthanareeswaran CLA 2013-02-26 00:06:23 EST
(In reply to comment #5)
> This is the signature passed to the Signature util:
> 
> (Ljava.lang.Object;)-*
> 
> Doesn't appear in the format the code is expecting.
> 
> Dani, what do you think?

Looking at the code and comments, I am confused. In the Util#scanTypeBoundSignature, I see these comments there:

		// need a minimum 1 char for wildcard

		// need a minimum 3 chars "+[I"

May be we are not expecting the "-" preceding the "*" in the case wildcards?
Comment 7 Dani Megert CLA 2013-02-26 05:53:55 EST
(In reply to comment #6)
> (In reply to comment #5)
> > This is the signature passed to the Signature util:
> > 
> > (Ljava.lang.Object;)-*
> > 
> > Doesn't appear in the format the code is expecting.
> > 
> > Dani, what do you think?
> 
> Looking at the code and comments, I am confused. In the
> Util#scanTypeBoundSignature, I see these comments there:
> 
> 		// need a minimum 1 char for wildcard
> 
> 		// need a minimum 3 chars "+[I"
> 
> May be we are not expecting the "-" preceding the "*" in the case wildcards?

Who is "we" and who do you expect to answer/investigate this?
Comment 8 Jay Arthanareeswaran CLA 2013-02-26 08:30:06 EST
(In reply to comment #7)
> Who is "we" and who do you expect to answer/investigate this?

I was just thinking aloud but also hoping that someone would know the answer, as I am not absolutely sure about the validity of the signature at this point of time.
Comment 9 Dani Megert CLA 2013-02-26 10:22:26 EST
Olivier, can you answer this?
Comment 10 Olivier Thomann CLA 2013-02-27 10:07:00 EST
(In reply to comment #9)
> Olivier, can you answer this?
I haven't checked signatures for a long time. I would need to check the current implementation to make a call. Might take some time with the current load :-(.
Comment 11 Stephan Herrmann CLA 2016-06-23 12:28:05 EDT

*** This bug has been marked as a duplicate of bug 496545 ***