Project: JDT
Bug 48325 introduce parameter throws NPE if there are compiler errors [refactoring]
Reported: 2003-12-09 04:37:59 | Status: resolved fixed

I200312020950 in the file below introduce the "3" as a parameter. -------------------------------------------------- class A { void method() { } void method() { int x = 3; //<-- introduce 3 as a parameter } } ---------------------------------------------------- the result is: ------------------------------------------------------ java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:313) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactorin g(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:409) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:472) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:395) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:263) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:430) 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:2294) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1975) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.IntroduceParameterAction.run (IntroduceParameterAction.java:69) 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:535) at org.eclipse.jface.action.ActionContributionItem.access$4 (ActionContributionItem.java:487) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:459) 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:2294) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1975) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1486) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1462) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:242) 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.applicationrunner.ApplicationRunnerActivator$1.run (ApplicationRunnerActivator.java:85) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.internal.boot.OSGiBootLoader.basicRun (OSGiBootLoader.java:239) at org.eclipse.core.internal.boot.OSGiBootLoader.run(OSGiBootLoader.java:665) at org.eclipse.core.internal.boot.OSGiBootLoader.run(OSGiBootLoader.java:652) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) 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.dom.Bindings.findMethod(Bindings.java:553) at org.eclipse.jdt.internal.corext.refactoring.code.IntroduceParameterRefactoring.f indAffectedCompilationUnits(IntroduceParameterRefactoring.java:412) at org.eclipse.jdt.internal.corext.refactoring.code.IntroduceParameterRefactoring.c hangeReferences(IntroduceParameterRefactoring.java:368) at org.eclipse.jdt.internal.corext.refactoring.code.IntroduceParameterRefactoring.c heckInput(IntroduceParameterRefactoring.java:327) 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.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) ... 49 more ----------------------------------------------

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameter/invalid/NoMethodBinding.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java