Bug 28822 - ClassCastException in ProblemBinding
Summary: ClassCastException in ProblemBinding
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-23 04:27 EST by Gunnar Wagenknecht CLA
Modified: 2003-02-07 12:15 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2002-12-23 04:27:45 EST
build: M4, occured during refactoring 
I tryed to rename a java source file with compilation errors. The exception 
didn't occure if i unchecked "update references..."


Caused by: java.lang.ClassCastException: 
org.eclipse.jdt.internal.compiler.lookup.ProblemBinding
	at 
org.eclipse.jdt.internal.core.search.matching.TypeReferencePattern.matchLevel
(TypeReferencePattern.java:470)
	at 
org.eclipse.jdt.internal.core.search.matching.TypeReferencePattern.matchLevel
(TypeReferencePattern.java:362)
	at org.eclipse.jdt.internal.core.search.matching.MatchSet.reportMatching
(MatchSet.java:258)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchingOpenable.locateMatchesInCo
mpilationUnit(MatchingOpenable.java:317)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchingOpenable.locateMatches
(MatchingOpenable.java:166)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:1236)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:533)
	at org.eclipse.jdt.core.search.SearchEngine.search
(SearchEngine.java:425)
	at 
org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search
(RefactoringSearchEngine.java:133)
	at 
org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search
(RefactoringSearchEngine.java:100)
	at 
org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search
(RefactoringSearchEngine.java:95)
	at 
org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeRefactoring.getRefe
rences(RenameTypeRefactoring.java:445)
	at 
org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeRefactoring.checkIn
put(RenameTypeRefactoring.java:314)
	at 
org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitRefactor
ing.checkInput(RenameCompilationUnitRefactoring.java:257)
	at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run
(CheckConditionsOperation.java:59)
	at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run
(CreateChangeOperation.java:94)
	at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run
(PerformChangeOperation.java:121)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread
(ModalContext.java:296)
	... 43 more
Comment 1 Jerome Lanneluc CLA 2003-01-06 04:59:39 EST
Would you have a simple test case that can reproduce the problem?
Comment 2 Gunnar Wagenknecht CLA 2003-01-06 05:04:43 EST
sorry, can't remeber 
Comment 3 Olivier Thomann CLA 2003-01-08 14:18:56 EST
The cast should not be done if the binding is a problem binding. Looking at the
source code, it looks like we missed a case in which we have to return a
INACCURATE_MATCH.
I suggest:
case BindingIds.TYPE : //=============only type ==============
	if (binding instanceof ProblemBinding) {
		return INACCURATE_MATCH;
	}
	typeBinding = (TypeBinding)binding;
	break;

instead of:

case BindingIds.TYPE : //=============only type ==============
	typeBinding = (TypeBinding)binding;
	break;

What do you think?
Comment 4 Jerome Lanneluc CLA 2003-01-09 05:48:57 EST
Thanks Olivier. Protection added.
Comment 5 Gunnar Wagenknecht CLA 2003-01-09 06:15:42 EST
I don't know the sourc background but why not doing a more stricter protection?

case BindingIds.TYPE : //=============only type ==============
	if (!(binding instanceof TypeBinding)) {
		return INACCURATE_MATCH;
	}
	typeBinding = (TypeBinding)binding;
	break;
Comment 6 Jerome Lanneluc CLA 2003-01-09 09:10:14 EST
Right. I released the change.
Comment 7 David Audel CLA 2003-02-07 12:15:53 EST
Verified.