Bug 78930 - ITypeBinding#getJavaElement() throws NPE for type variable
Summary: ITypeBinding#getJavaElement() throws NPE for type variable
Status: VERIFIED 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 M4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-18 05:55 EST by Markus Keller CLA
Modified: 2004-12-15 05:32 EST (History)
1 user (show)

See Also:


Attachments
Apply on HEAD (1.85 KB, patch)
2004-11-18 21:06 EST, Olivier Thomann CLA
no flags Details | Diff
Apply on HEAD (1.93 KB, patch)
2004-11-19 15:09 EST, Olivier Thomann CLA
no flags Details | Diff
Apply on HEAD on TYpeBinding (1.87 KB, patch)
2004-11-24 18:41 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2004-11-18 05:55:40 EST
I200411170800

ITypeBinding#getJavaElement() throws NPE for type variable <E extends Object>:

class Y {
	<E extends Object> void m(E e) {}
}

java.lang.NullPointerException
	at
org.eclipse.jdt.core.compiler.CharOperation.replaceOnCopy(CharOperation.java:2316)
	at org.eclipse.jdt.core.dom.TypeBinding.getCompilationUnit(TypeBinding.java:289)
	at org.eclipse.jdt.core.dom.TypeBinding.getJavaElement(TypeBinding.java:507)
...
Comment 1 Olivier Thomann CLA 2004-11-18 21:06:16 EST
Jérôme, do we expect a Java element to be found in this case?
If not, I will attach a patch that solves the NPE issue, but returns null.
Comment 2 Olivier Thomann CLA 2004-11-18 21:06:44 EST
Created attachment 16002 [details]
Apply on HEAD
Comment 3 Olivier Thomann CLA 2004-11-19 15:09:52 EST
Created attachment 16020 [details]
Apply on HEAD
Comment 4 Markus Keller CLA 2004-11-22 04:22:22 EST
I would expect that we get the corresponding ITypeParameter in this case.
Comment 5 Jerome Lanneluc CLA 2004-11-22 09:38:14 EST
Changed TypeBinding#getJavaElement() to return an ITypeParameter in the case of
a type variable binding.

Added regression test ASTModelBridgeTests#testTypeParameter()
Comment 6 Olivier Thomann CLA 2004-11-24 18:41:23 EST
Jérôme, I enable the test0071 in ASTConverter15Test and I got a
ClassCastException. I will attach a patch that I released in HEAD.
Could you please verify that change?
Thanks.
Comment 7 Olivier Thomann CLA 2004-11-24 18:41:50 EST
Created attachment 16119 [details]
Apply on HEAD on TYpeBinding
Comment 8 Jerome Lanneluc CLA 2004-11-25 04:48:26 EST
Fix is good. Thanks Olivier.
Comment 9 Frederic Fusier CLA 2004-12-15 05:32:40 EST
Verified for 3.1 M4 using build I200412142000.