Project: JDT
Bug 112076 Moving method from anonymous inner type throws InvocationTargetException
Reported: 2005-10-09 21:30:47 | Status: verified fixed

In M2: Given code: import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class TestKindRegistry { public class TestKind { public String getPrecededKindIds() { return null; } public String getId() { return null; } } public ArrayList getAllKinds() { ArrayList items = new ArrayList(); Collections.sort(items, new Comparator() { public int compare(Object arg0, Object arg1) { TestKind kind0 = (TestKind) arg0; TestKind kind1 = (TestKind) arg1; if (precedes(kind0, kind1)) return -1; if (precedes(kind1, kind0)) return 1; return 0; } private boolean precedes(TestKind kind0, TestKind kind1) { // REF: move to kind0 final String precededKindId = kind0.getPrecededKindIds(); String[] ids = precededKindId.split(","); //$NON-NLS-1$ for (int i = 0; i < ids.length; i++) { if (ids[i].equals(kind1.getId())) return true; } return false; } }); return items; } } The refactoring fails with exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:327) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:293) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:547) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:613) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:417) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:409) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:556) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:884) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3194) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2823) at org.eclipse.jface.window.Window.runEventLoop(Window.java:809) at org.eclipse.jface.window.Window.open(Window.java:787) 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.corext.refactoring.RefactoringExecutionStarter.startMoveMethodRefactoring(RefactoringExecutionStarter.java:287) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveInstanceMethodAction.run(MoveInstanceMethodAction.java:140) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveInstanceMethodAction.run(MoveInstanceMethodAction.java:124) at org.eclipse.jdt.ui.actions.MoveAction.tryMoveInstanceMethod(MoveAction.java:203) at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:145) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:226) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:198) at org.eclipse.jface.action.Action.runWithEvent(Action.java:996) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:108) at org.eclipse.core.commands.Command.execute(Command.java:311) at org.eclipse.core.commands.ParameterizedCommand.execute(ParameterizedCommand.java:397) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:459) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:781) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:828) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:550) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:493) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:117) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:971) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:883) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:908) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:893) at org.eclipse.swt.widgets.Control.traverse(Control.java:2794) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2635) at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:856) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2653) at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:3628) at org.eclipse.swt.widgets.Display.filterMessage(Display.java:985) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2819) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1755) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1719) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:368) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:377) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:164) 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.core.launcher.Main.invokeFramework(Main.java:338) at org.eclipse.core.launcher.Main.basicRun(Main.java:282) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952) Caused by: java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.SimpleName.setIdentifier(SimpleName.java:189) at org.eclipse.jdt.core.dom.AST.newSimpleName(AST.java:1248) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor$1.getTargetNode(MoveInstanceMethodProcessor.java:1734) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createArgumentList(MoveInstanceMethodProcessor.java:1466) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createMethodArguments(MoveInstanceMethodProcessor.java:1695) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createMethodCopy(MoveInstanceMethodProcessor.java:1912) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createChangeManager(MoveInstanceMethodProcessor.java:1531) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.checkFinalConditions(MoveInstanceMethodProcessor.java:1097) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:169) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:189) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1719) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:86) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java