Project: JDT
Bug 83593 Rename of enum type does not update constructor / throws ClassCastException
Reported: 2005-01-25 04:47:47 | Status: verified fixed

I20050118-1015 + jdt.core v_532b ICompilationUnit#rename(..) of an enum type does not update constructors. For consistency with rename of a class, enum constructors should be updated too. After uncommenting the enum constant TURQUOISE, renaming Color yields the ClassCastException below. public enum Color { PINK, // TURQUOISE(1) { // int getNumber() { // return fNumber; // } // } ; Color c; int fNumber; public Color() { } public Color(int num) { fNumber= num; } } java.lang.ClassCastException: org/eclipse/jdt/core/dom/EnumConstantDeclaration incompatible with org/eclipse/jdt/core/dom/ClassInstanceCreation at org.eclipse.jdt.internal.core.util.DOMFinder.visit(DOMFinder.java:89) at org.eclipse.jdt.core.dom.AnonymousClassDeclaration.accept0(AnonymousClassDeclaration.java:139) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497) at org.eclipse.jdt.core.dom.EnumConstantDeclaration.accept0(EnumConstantDeclaration.java:291) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520) at org.eclipse.jdt.core.dom.EnumDeclaration.accept0(EnumDeclaration.java:288) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520) at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:291) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.internal.core.util.DOMFinder.search(DOMFinder.java:72) at org.eclipse.jdt.internal.core.SourceRefElement.findNode(SourceRefElement.java:99) at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.updateTypeName(CopyResourceElementsOperation.java:648) at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.updatedContent(CopyResourceElementsOperation.java:575) at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processCompilationUnitResource(CopyResourceElementsOperation.java:233) at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processElement(CopyResourceElementsOperation.java:373) at org.eclipse.jdt.internal.core.MultiOperation.processElements(MultiOperation.java:162) at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processElements(CopyResourceElementsOperation.java:391) at org.eclipse.jdt.internal.core.MultiOperation.executeOperation(MultiOperation.java:90) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:710) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1703) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:754) at org.eclipse.jdt.internal.core.JavaModel.rename(JavaModel.java:303) at org.eclipse.jdt.internal.core.CompilationUnit.rename(CompilationUnit.java:1092) at org.eclipse.jdt.internal.corext.refactoring.changes.RenameCompilationUnitChange.doRename(RenameCompilationUnitChange.java:64) at org.eclipse.jdt.internal.corext.refactoring.AbstractJavaElementRenameChange.perform(AbstractJavaElementRenameChange.java:67) at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:262) at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.access$0(DynamicValidationStateChange.java:1) at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange$1.run(DynamicValidationStateChange.java:76) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:710) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1703) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3582) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3539) at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.perform(DynamicValidationStateChange.java:79) at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:262) at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:231) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1703) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1723) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:279) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.access$4(UIPerformChangeOperation.java:1) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation$1.run(UIPerformChangeOperation.java:70) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2787) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2458) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:151) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:301) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:539) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:605) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:396) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:543) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2810) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2455) at org.eclipse.jface.window.Window.runEventLoop(Window.java:718) at org.eclipse.jface.window.Window.open(Window.java:696) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:125) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:138) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameUserInterfaceStarter.activate(RenameUserInterfaceStarter.java:113) at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:178) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:131) at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:116) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:989) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:188) at org.eclipse.ui.internal.commands.Command.execute(Command.java:130) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:445) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:724) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:767) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:536) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:479) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:221) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:758) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:832) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.traverse(Control.java:2765) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2606) at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:786) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2624) at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:3230) at org.eclipse.swt.widgets.Display.filterMessage(Display.java:772) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2451) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1575) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1541) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:287) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:274) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.basicRun(Main.java:255) at org.eclipse.core.launcher.Main.run(Main.java:811) at org.eclipse.core.launcher.Main.main(Main.java:795)

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTypeTests.java