Bug 72772 - [1.5][Search Engine] ClassCastException: org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding
Summary: [1.5][Search Engine] ClassCastException: org.eclipse.jdt.internal.compiler.lo...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1 M2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-27 06:48 EDT by Tobias Widmer CLA
Modified: 2004-09-23 07:30 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Widmer CLA 2004-08-27 06:48:50 EDT
Build I20040824: Searching method declaration references does not work with 
classes having type parameters.

Stack trace:
java.lang.ClassCastException: 
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding
	at 
org.eclipse.jdt.internal.core.search.matching.MethodLocator.reportDeclaration
(MethodLocator.java:192)
	at 
org.eclipse.jdt.internal.core.search.matching.MethodLocator.matchReportReferenc
e(MethodLocator.java:154)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching
(MatchLocator.java:1408)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching
(MatchLocator.java:1643)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching
(MatchLocator.java:1498)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process
(MatchLocator.java:1162)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:766)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:805)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:921)
	at 
org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches
(JavaSearchParticipant.java:94)
	at org.eclipse.jdt.core.search.SearchEngine.searchDeclarations
(SearchEngine.java:1066)
	at 
org.eclipse.jdt.core.search.SearchEngine.searchDeclarationsOfSentMessages
(SearchEngine.java:1300)
	at 
org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getMe
thodReferencesIn(ReferenceFinderUtil.java:112)
	at 
org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getMe
thodReferencesIn(ReferenceFinderUtil.java:104)
	at 
org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getMe
thodsReferencedIn(ReferenceFinderUtil.java:95)

aso.
Comment 1 Kent Johnson CLA 2004-08-30 16:40:59 EDT
I tried some cases & they worked fine for me.

Do you have a testcase that fails?
Comment 2 Tobias Widmer CLA 2004-08-31 04:15:40 EDT
The problem only occurs with the new 1.5 implementation of the push down/pull 
up refactoring which has not been released yet. I was hoping that the error 
could be understood based on the stack trace.

After some investigation, I am now able to give some more information:

The problem occurs if parameterized type bindings occur. Consider a generic 
class A<T> with a method "public void bar(){}" and a class B<R> which extends 
A and has a method "public void foo(){super.bar()}"

Calling 
org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getMe
thodsReferencedIn(IJavaElement[],IProgressMonitor) with a java element array 
containing the java element corresponding to B#foo yields the class cast 
exception in MethodLocator, line 192 (see stack trace)

Variable "declaringClass" is a parameterized type binding which does not 
extend source type bindings. Therefore the exception.


Comment 3 Kent Johnson CLA 2004-08-31 10:49:22 EDT
But when you construct your case, you can find references to the method foo() 
without any problems... so the problem is likely in the way the refactoring 
code is calling the SearchEngine.

I'll look into protecting ourselves against this, but you should look into how 
you call the SearchEngine.
Comment 4 Kent Johnson CLA 2004-08-31 10:57:44 EDT
I can duplicate this now with the existing 'push down' code... I'll look into 
it further.
Comment 5 Kent Johnson CLA 2004-08-31 11:20:26 EDT
Fixed. We now protect the 3 places where he expect SourceTypeBindings.

If a Parameterized or Raw type shows up, we'll extract the SourceTypeBinding.
Comment 6 David Audel CLA 2004-09-23 07:30:24 EDT
Verified in I200409240100.