Project: JDT
Bug 209500 ClassCastException using rename method refactoring
Reported: 2007-11-12 09:58:30 | Status: verified fixed

Hi, I got the following error during a rename refactoring on a method. -- Error Log -- Date: Mon Nov 12 14:52:22 GMT 2007 Message: Internal Error Severity: Error Plugin ID: org.eclipse.ltk.ui.refactoring Stack Trace: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:350) at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:758) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:755) at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2451) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:579) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:422) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.getStartingPage(RefactoringWizard.java:405) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.createContents(RefactoringWizardDialog2.java:594) at org.eclipse.jface.window.Window.create(Window.java:426) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1081) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:133) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:154) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:49) at org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:60) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameUserInterfaceStarter.activate(RenameUserInterfaceStarter.java:31) at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:158) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameLinkedMode.doRename(RenameLinkedMode.java:337) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameLinkedMode$EditorSynchronizer.left(RenameLinkedMode.java:113) at org.eclipse.jface.text.link.LinkedModeModel.exit(LinkedModeModel.java:339) at org.eclipse.jface.text.link.LinkedModeUI$4.run(LinkedModeUI.java:1190) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3659) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3296) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447) at org.eclipse.equinox.launcher.Main.run(Main.java:1173) at org.eclipse.equinox.launcher.Main.main(Main.java:1148) Caused by: java.lang.ClassCastException: org.eclipse.jdt.internal.core.ImportDeclaration cannot be cast to org.eclipse.jdt.core.IMember at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor$2.acceptSearchMatch(RenameMethodProcessor.java:389) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report(MatchLocator.java:1684) at org.eclipse.jdt.internal.core.search.matching.MethodLocator.matchReportReference(MethodLocator.java:354) at org.eclipse.jdt.internal.core.search.matching.PatternLocator.matchReportImportRef(PatternLocator.java:366) at org.eclipse.jdt.internal.core.search.matching.PatternLocator.matchLevelAndReportImportRef(PatternLocator.java:350) at org.eclipse.jdt.internal.core.search.matching.MethodLocator.matchLevelAndReportImportRef(MethodLocator.java:205) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2147) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1559) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1037) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1078) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1199) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:217) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:502) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:550) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.searchForOuterTypesOfReferences(RenameMethodProcessor.java:398) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.doCheckFinalConditions(RenameMethodProcessor.java:322) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor.doCheckFinalConditions(RenameNonVirtualMethodProcessor.java:87) at org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor.checkFinalConditions(JavaRenameProcessor.java:48) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:174) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:118) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113) Root exception: java.lang.ClassCastException: org.eclipse.jdt.internal.core.ImportDeclaration cannot be cast to org.eclipse.jdt.core.IMember at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor$2.acceptSearchMatch(RenameMethodProcessor.java:389) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report(MatchLocator.java:1684) at org.eclipse.jdt.internal.core.search.matching.MethodLocator.matchReportReference(MethodLocator.java:354) at org.eclipse.jdt.internal.core.search.matching.PatternLocator.matchReportImportRef(PatternLocator.java:366) at org.eclipse.jdt.internal.core.search.matching.PatternLocator.matchLevelAndReportImportRef(PatternLocator.java:350) at org.eclipse.jdt.internal.core.search.matching.MethodLocator.matchLevelAndReportImportRef(MethodLocator.java:205) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2147) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1559) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1037) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1078) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1199) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:217) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:502) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:550) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.searchForOuterTypesOfReferences(RenameMethodProcessor.java:398) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.doCheckFinalConditions(RenameMethodProcessor.java:322) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor.doCheckFinalConditions(RenameNonVirtualMethodProcessor.java:87) at org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor.checkFinalConditions(JavaRenameProcessor.java:48) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:174) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:118) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/testFail41/in/A.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameVirtualMethodInClassTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java