Project: JDT
Bug 314063 [extract interface] NPE while 'Extract Interface', 'Use SuperType', 'Extract class' when CU not on Build path
Reported: 2010-05-24 04:12:44 | Status: verified fixed

Build I20100520-1744 - New workspace - CVS Repositories view -> Navigate to a Java file stored in a CVS repository -> Right click, select 'Open' from the context menu (I used org.eclipse.jdt.ui.tests.AutomatedSuite) OR Open a Java file placed anywhere on the file system (but is not on build path) - Select a line of code - From the Menu bar 'Refactor' -> Extract interface => following NPE in error log java.lang.NullPointerException at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringActions.convertToEnclosingOrPrimaryType(RefactoringActions.java:53) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringActions.getEnclosingOrPrimaryType(RefactoringActions.java:46) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:138) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:230) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:234) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574) at org.eclipse.equinox.launcher.Main.run(Main.java:1407)

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ExtractClassAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ExtractInterfaceAction.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/UseSupertypeAction.java