Bug 127739 - IAE in Signature.getReturnType while hovering a method of type having $ in its name
Summary: IAE in Signature.getReturnType while hovering a method of type having $ in it...
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.4 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-14 10:53 EST by Frederic Fusier CLA
Modified: 2008-02-04 15:52 EST (History)
2 users (show)

See Also:


Attachments
Proposed fix and regression tests (4.60 KB, patch)
2008-01-17 12:42 EST, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2006-02-14 10:53:49 EST
Follow-up of bug 125301 comment 5 point 1. See bug 125301 comment 3 for test case details...

Stack trace is:
java.lang.IllegalArgumentException
        at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1633)
        at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1649)
        at org.eclipse.jdt.ui.JavaElementLabels.getMethodLabel(JavaElementLabels.java:502)
        at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:410)
        at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:387)
        at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getInfoText(JavadocHover.java:144)
        at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:119)
        at org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:112)
        at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
        at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
        at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:160)
Comment 1 Jerome Lanneluc CLA 2006-02-14 11:36:51 EST
BindingKey.toSignature() returns the type signature for a method belonging to such a type. Would need to escape $ in binding key.
Comment 2 Jerome Lanneluc CLA 2007-06-21 12:26:10 EDT
Reproduce using 3.3RC4:

1. Create the following classes (in separate files):

public class A$B {
        public void m() {
        }
}

public class X {
        void foo() {
                new A$B().m();
        }
}

2. Hover over m in 'new A$B().m()'
Observe: you get the following exception in the .log:
!ENTRY org.eclipse.jface.text 4 0 2007-06-21 18:23:45.406
!MESSAGE Unexpected runtime error while computing a text hover
!STACK 0
java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1641)
	at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1657)
	at org.eclipse.jdt.ui.JavaElementLabels.getMethodLabel(JavaElementLabels.java:510)
	at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:427)
	at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:404)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getInfoText(JavadocHover.java:225)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:173)
	at org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:125)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
	at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:165)
Comment 3 Stephan Herrmann CLA 2008-01-10 16:42:36 EST
I'm seeing the same with a regular method whose name contains '$'.

Question: why is BindingKeyParser.nextToken() interpreting '$'
as a delimiter? I just commented that line (186 in BindingKeyParser v1.32)
and getMethodLabel() worked fine in my case.

I couldn't quickly find documentation for the syntax of binding keys.
Is '$' used as a delimiter other than for Outer$Inner classes?

It seems, the case of '$' in a method name could be solved by
adding a flag to nextToken() in order to interpret '$' only
while parsing a type name?
Comment 4 Jerome Lanneluc CLA 2008-01-17 12:41:33 EST
Actually, in getFullQualifiedName() we don't know beforehand if A$B is the member type name, or the name of cu that contains the type (see parseSecondaryType()). Thus we cannot pass a flag to getNextToken().

However getNextToken() can be fixed to handle this case.
Comment 5 Jerome Lanneluc CLA 2008-01-17 12:42:47 EST
Created attachment 87181 [details]
Proposed fix and regression tests
Comment 6 Jerome Lanneluc CLA 2008-01-18 10:32:23 EST
Fix and tests released for 3.4M5
Comment 7 Kent Johnson CLA 2008-02-04 15:52:06 EST
Verified for 3.4M5 using I20080204-0010