Bug 47062 Change method signature: Refactor fails for methods/ctors used in static initializers [refactoring]
I have type-safe enum code similar to the class below. If I try to make any change to the constructor or static method using "Change Method Signature", the operation fails with "Internal error while creating a change object". This only happens when the method in question is called from a static initializer as in the example. Using build 200311190010. public class Example { /* This block breaks refactoring on constructor or factory. */ public static final Example A = new Example("A", "A"); public static final Example B = Example.getExample("B", "B"); /* This block breaks refactoring on constructor or factory. */ public static final Example C; public static final Example D; static { C = new Example("C", "C"); D = Example.getExample("D", "D"); } public Example(String arg1, String arg2) { } public static Example getExample(String arg1, String arg2) { return new Example(arg1, arg2); } } *** Error Log: !SESSION Nov 20, 2003 09:31:18.796 -------------------------------------------- - java.version=1.4.2_01 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 -data D:\workspace\axiope -install file:C:/eclipse/ !ENTRY org.eclipse.jdt.ui 4 10001 Nov 20, 2003 09:31:18.796 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange (RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSucce ssorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSucce ssorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage (UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed (RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3 (RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2 $1.widgetSelected(RefactoringWizardDialog2.java:547) 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:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:180) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:124) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:196) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4 (ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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.basicRun(Main.java:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.isRecursiveReference(ChangeSignatureRefactoring.java:1401) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.reshuffleElements(ChangeSignatureRefactoring.java:1162) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateReferenceNode(ChangeSignatureRefactoring.java:1156) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateMethodOccurrenceNode(ChangeSignatureRefactoring.java:987) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createChangeManager(ChangeSignatureRefactoring.java:966) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkInput(ChangeSignatureRefactoring.java:521) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/canModify/A_testAddRecursive1_in.java
package p;
public class A {
	int i;
	void m(int i) {this.i = i;}
}
class Super extends A {