Project: JDT
Bug 190700 [convert local] NPE in PromoteTempToFieldRefactoring.checkTempTypeForLocalTypeUsage
Reported: 2007-06-03 14:48:12 | Status: verified fixed

java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:350) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:495) at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:268) at org.eclipse.ui.internal.progress.ProgressManager$3.run(ProgressManager.java:909) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:944) at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:919) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.checkInitialConditions(RefactoringWizardOpenOperation.java:166) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.access$0(RefactoringWizardOpenOperation.java:162) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:125) 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.ui.actions.ConvertLocalToFieldAction.run(ConvertLocalToFieldAction.java:86) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:272) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:244) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1495) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1519) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1504) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1295) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3349) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2953) at org.eclipse.jdt.internal.ui.actions.QuickMenuAction.run(QuickMenuAction.java:75) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:119) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:475) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:429) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:165) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:821) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:879) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:568) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1100) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1494) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1519) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1504) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1556) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1551) at org.eclipse.swt.widgets.Control.kEventUnicodeKeyPressed(Control.java:2090) at org.eclipse.swt.widgets.Composite.kEventUnicodeKeyPressed(Composite.java:580) at org.eclipse.swt.widgets.Control.kEventTextInputUnicodeForKeyEvent(Control.java:2071) at org.eclipse.swt.widgets.Widget.textInputProc(Widget.java:1925) at org.eclipse.swt.widgets.Display.textInputProc(Display.java:3805) at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2937) 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:153) 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(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443) at org.eclipse.equinox.launcher.Main.run(Main.java:1169) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring.checkTempTypeForLocalTypeUsage(PromoteTempToFieldRefactoring.java:398) at org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring.checkInitialConditions(PromoteTempToFieldRefactoring.java:317) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:81) 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) @@@@ This happens if the class has a compile error: import java.util.Date; class Test { void a() {} void a() { Date date = new Date(2006, 5, 3); } } Try to refactor "date" into a field.

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/PromoteTempToField/canPromote/A_testDeclaringMethodBindingUnavailable01_in.java org.eclipse.jdt.ui.tests.refactoring/resources/PromoteTempToField/canPromote/A_testDeclaringMethodBindingUnavailable01_out.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/PromoteTempToFieldRefactoring.java