Bug 83646 - NPE renaming package
Summary: NPE renaming package
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-25 14:42 EST by John Arthorne CLA
Modified: 2005-02-15 11:08 EST (History)
2 users (show)

See Also:


Attachments
Log file (17.20 KB, text/plain)
2005-01-25 14:42 EST, John Arthorne CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2005-01-25 14:42:09 EST
Build: I20050118

I got the following NPE while renaming a Java package.  I have zipped up my
project and can make it available if necessary.

java.lang.NullPointerException
	at
org.eclipse.jdt.internal.debug.core.refactoring.JavaBreakpointTypeChange.performPackageRename(JavaBreakpointTypeChange.java:336)
	at
org.eclipse.jdt.internal.debug.core.refactoring.JavaBreakpointTypeChange.perform(JavaBreakpointTypeChange.java:241)
	at
org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:262)
	at
org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:231)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1703)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1723)
	at
org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:279)
	at
org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.access$4(UIPerformChangeOperation.java:1)
	at
org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation$1.run(UIPerformChangeOperation.java:70)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2787)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2458)
	at
org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:151)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:301)
	at
org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282)
	at
org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:539)
	at
org.eclipse.ltk.internal.ui.refactoring.PreviewWizardPage.performFinish(PreviewWizardPage.java:175)
	at
org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:605)
	at
org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:406)
	at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:396)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:543)
	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:833)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2810)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2455)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:718)
	at org.eclipse.jface.window.Window.open(Window.java:696)
	at
org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:125)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at
org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:138)
	at
org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40)
	at
org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:56)
	at
org.eclipse.jdt.internal.ui.refactoring.reorg.RenameUserInterfaceStarter.activate(RenameUserInterfaceStarter.java:113)
	at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:114)
	at
org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:178)
	at
org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:99)
	at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:107)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:989)
	at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:555)
	at
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505)
	at
org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:419)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2810)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2455)
Comment 1 John Arthorne CLA 2005-01-25 14:42:32 EST
Created attachment 17431 [details]
Log file
Comment 2 Dirk Baeumer CLA 2005-01-26 04:42:35 EST
The NPE happens in the Debug participant. Moving to Debug.
Comment 3 Luc Bourlier CLA 2005-01-26 15:15:34 EST
The NPE appears when trying to rename a package to a sub-package of itself
(test -> test.sub), if the package contains Java breakpoints.

The Java Breakpoint participants rely on the fact than when perform() is called,
the workspace is already in the new state (the 'after refactoring' state). But
in this case, the state of the workspace doesn't look good.

If the project was :

Project Test
+ package test
  + compilation unit HW.java

When the perform() method of the change is called, the project still looks the same.
I would have excepted it to look like :

Project Test
+ package test
+ package test.sub
  + compilation unit HW.java

The consequense is project.findType("test.sub.HW") returns null, and an NPE is
thrown when we try to use this value.

It's only a problem when renaming to a sub package. It works fine in the other
cases (test.sub1 -> tes2.subA, test.sub -> test).

Moving to JDT/UI for comment.
Comment 4 Dirk Baeumer CLA 2005-01-27 05:39:50 EST
The refactoring calls IPackageFragment#rename("test.sub", false, pm);

The renaming is executed correctly, but if I ask the package fragment root after
the rename for its package I still get only "test" not "test" and "test.sub" (as
Lus pointed out).

Moving to JDT/Core for comments. The Java Model should reflect the changes in
all cases.

Luc, is it possible that Debug protects itself against the NPE. I all cases it
is better to log this and do nothing instead of blowing up the refactoring.
Comment 5 Jerome Lanneluc CLA 2005-01-28 06:42:23 EST
Changed JavaModelOperation#run(...) to close the parent element of the created
element and to reset the corresponding project's cache.
Added regresison test RenameTests#testRenamePF3()
Comment 6 David Audel CLA 2005-02-15 11:08:49 EST
Verified in I20050214-0927