Community
Participate
Working Groups
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
Would you have a simple test case that can reproduce the problem?
sorry, can't remeber
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?
Thanks Olivier. Protection added.
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;
Right. I released the change.
Verified.