Project: JDT
Bug 62603 NPE in JavaTypeCompletionProcessor [refactoring]
Reported: 2004-05-18 04:25:12 | Status: resolved fixed

I20040514 + ZRH plug-ins from 20040518 1. Have this java class: <pre> package org.eclipse.jdt.text.tests; import java.text.CharacterIterator; import junit.framework.Assert; import junit.framework.TestCase; import org.eclipse.jdt.internal.ui.text.WordNavigator; /** * @since 3.0 */ public class WordNavigationTest extends TestCase { private WordNavigator fWordNavigator; /* * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { fWordNavigator= new WordNavigator(); } public void testNext1() { CharacterIterator it= null; int pos= fWordNavigator.next(it); Assert.assertEquals(5, pos); } } </pre> 2. Select the two last lines of method testNext1 3. Press Alt+Shift+M to extract method -> get this: !ENTRY org.eclipse.ui 4 4 May 18, 2004 10:07:37.267 !MESSAGE The command for the key you pressed failed The command for the key you pressed failed Reason: !ENTRY org.eclipse.ui 4 0 May 18, 2004 10:07:37.295 !MESSAGE The command for the key you pressed failed !STACK 0 java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:60) at org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor.setPackageFragment(JavaTypeCompletionProcessor.java:55) at org.eclipse.jdt.internal.ui.refactoring.ChangeParametersControl.installParameterTypeContentAssist(ChangeParametersControl.java:640) at org.eclipse.jdt.internal.ui.refactoring.ChangeParametersControl.addCellEditors(ChangeParametersControl.java:552) at org.eclipse.jdt.internal.ui.refactoring.ChangeParametersControl.createParameterList(ChangeParametersControl.java:281) at org.eclipse.jdt.internal.ui.refactoring.ChangeParametersControl.<init>(ChangeParametersControl.java:212) at org.eclipse.jdt.internal.ui.refactoring.ChangeParametersControl.<init>(ChangeParametersControl.java:182) at org.eclipse.jdt.internal.ui.refactoring.code.ExtractMethodInputPage.createControl(ExtractMethodInputPage.java:150) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.createContents(RefactoringWizardDialog2.java:533) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:924) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExtractMethodAction.run(ExtractMethodAction.java:98) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:141) at org.eclipse.ui.internal.commands.Command.execute(Command.java:132) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:927) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:545) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:493) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:258) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Display.filterEvent(Display.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:2284) at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java) at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(Native Method) at org.eclipse.swt.widgets.Display.eventProc(Display.java) at org.eclipse.swt.internal.gtk.OS.gtk_main_iteration(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:243) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:298) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:249) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:126) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41) at java.lang.reflect.Method.invoke(Method.java:386) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:722) at org.eclipse.core.launcher.Main.main(Main.java:706)

Files changed in fix:
org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/CUPositionCompletionProcessor.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java