Bug 96858 - IllegalArgumentException in Signature
Summary: IllegalArgumentException in Signature
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-26 15:36 EDT by Kent Johnson CLA
Modified: 2005-06-10 08:45 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (1.51 KB, patch)
2005-05-29 05:09 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Regression test (813 bytes, patch)
2005-05-29 05:09 EDT, 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 Kent Johnson CLA 2005-05-26 15:36:41 EDT
With the following in the same file:

package p1;
class Test<
	T extends Test<T, B>,
	B extends Key<T, B>> {
}
class Key<
	T extends Test<T, K>,
	K extends Key<T, K>> {
}

Exception in thread "Text Viewer Hover Presenter" 
java.lang.IllegalArgumentException
  at  o.e.j.core.Signature.getTypeParameters(Signature.java:1374)
  at  o.e.j.core.Signature.getTypeParameters(Signature.java:1431)
  at  o.e.j.ui.JavaElementLabels.getTypeLabel(JavaElementLabels.java:821)
  at  o.e.j.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:398)
  at  o.e.j.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:363)
  at  o.e.j.internal.ui.text.java.hover.JavadocHover.getInfoText
(JavadocHover.java:142)
  at  o.e.j.internal.ui.text.java.hover.JavadocHover.getHoverInfo
(JavadocHover.java:118)
  at  
o.e.j.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo
(AbstractJavaEditorTextHover.java:120)
  at  o.e.j.internal.ui.text.java.hover.BestMatchHover.getHoverInfo
(BestMatchHover.java:102)
  at  o.e.j.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo
(JavaEditorTextHoverProxy.java:69)
  at org.eclipse.jface.text.TextViewerHoverManager$4.run
(TextViewerHoverManager.java:160)
Comment 1 Olivier Thomann CLA 2005-05-27 14:37:49 EDT
This is suspicious.

The binding key is:
Lp/X~Test<TT;TB;>;

And the corresponding signature ends up being:
<T:>Lp.X~Test;

The label seems wrong. We end up with Test<T> instead of the expecting
Test<T, B>.

This leads to a wrong label when hovering on Test in "T extends Test<T, B>".

For Key in "B extends Key<T, B>", the binding key is:
Lp/X~Key<Lp/X~Test;:TT;Lp/X~Test;:TB;>;

And then the label is as expected: Key<T, B>.

Moving to JDT/UI to investigate if KeyToSignature is working as expected.

Philippe, I put you in CC, because the binding for Test<T, B> is seen as a
generic type and the binding for Key<T, B> is seend as a parameterized type.
This doesn't look consistent.
Comment 2 Dirk Baeumer CLA 2005-05-27 17:23:27 EDT
Olivier,

I actually don't understand your question. The code on JDT/UI side looks as follows:

if (getFlag(flags, T_TYPE_PARAMETERS)) {
	if (getFlag(flags, USE_RESOLVED) && type.isResolved()) {
		BindingKey key= new BindingKey(type.getKey());
		if (key.isParameterizedType()) {
			String[] typeArguments= key.getTypeArguments();
			getTypeArgumentSignaturesLabel(typeArguments, flags, buf);
		} else {
			String[] typeParameters= Signature.getTypeParameters(key.internalToSignature());
			getTypeParameterSignaturesLabel(typeParameters, flags, buf);
				}
	} else if (type.exists()) {
               ...
	}
}

KeyToSignature is an internal JDT/Core class. However what we expect is that
BindingKey#getTypeArguments (which uses KeyToSignature) returns an array of type
signatures for parameterized types.

Moving back to JDT/Core.
Comment 3 Jerome Lanneluc CLA 2005-05-28 04:30:58 EDT
Indeed, problem is on our side. Thanks Dirk.
Comment 4 Jerome Lanneluc CLA 2005-05-29 05:09:19 EDT
Created attachment 21932 [details]
Proposed fix
Comment 5 Jerome Lanneluc CLA 2005-05-29 05:09:45 EDT
Created attachment 21933 [details]
Regression test
Comment 6 Philipe Mulet CLA 2005-05-30 06:19:01 EDT
+1 for RC2
Comment 7 Jerome Lanneluc CLA 2005-05-30 08:44:41 EDT
Released fix and test.
Comment 8 Olivier Thomann CLA 2005-06-06 20:05:03 EDT
Verified in N20050606-0010
Comment 9 Frederic Fusier CLA 2005-06-10 08:45:50 EDT
Verified for 3.1 RC2 using build I20050610-0010