Bug 48706 - NPE in move refactoring
Summary: NPE in move refactoring
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.0 M6   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-14 10:39 EST by Sebastian Davids CLA
Modified: 2003-12-18 12:11 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2003-12-14 10:39:54 EST
Version: 3.0.0
Build id: 200311251047

This was my setup:

Project A ... several references to class "import x.y.z.ClassName"; Project B on
classpath.

Project B ... existing package "x.y.z.test" containing class "ClassNameTest",
the parent package "x.y.z" was empty.

I now imported ClassName into the default package (mistake on my side here).

I now invoked "Refactor/Move..." on that CU and selected "x.y.z" ... OK.

After a few seconds I changed my mind and pressed "Abort".

I'm not sure if the stuff below was appended to the log before I pressed Abort
or after.

Log entries:

!ENTRY org.eclipse.jdt.ui 4 10001 Dez 14, 2003 16:28:36.840
!MESSAGE Internal Error
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:715)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1555)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1574)
	at org.eclipse.jdt.internal.core.JavaElement.runOperation(JavaElement.java:528)
	at org.eclipse.jdt.internal.core.JavaModel.runOperation(JavaModel.java:315)
	at org.eclipse.jdt.internal.core.JavaModel.move(JavaModel.java:276)
	at org.eclipse.jdt.internal.core.CompilationUnit.move(CompilationUnit.java:950)
	at
org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange.doPeform(MoveCompilationUnitChange.java:72)
	at
org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitReorgChange.perform(CompilationUnitReorgChange.java:60)
	at
org.eclipse.jdt.internal.corext.refactoring.CompositeChange.createUndoList(CompositeChange.java:122)
	at
org.eclipse.jdt.internal.corext.refactoring.CompositeChange.perform(CompositeChange.java:149)
	at
org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:173)
	at
org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.execute(JavaModelOperation.java:367)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:706)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1555)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1574)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:2975)
	at
org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:183)
	at
org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:145)
	at
org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:302)
	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.performRefactoring(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.reorg.ReorgMoveWizard$MoveInputPage.performFinish(ReorgMoveWizard.java:91)
	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:2296)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1977)
	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.internal.ui.refactoring.reorg.ReorgMoveAction.startRefactoring(ReorgMoveAction.java:120)
	at
org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:106)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172)
	at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:123)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194)
	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:542)
	at
org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494)
	at
org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466)
	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:2296)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1977)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237)
	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.boot.InternalBootLoader.run(InternalBootLoader.java:852)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	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)
!ENTRY org.eclipse.jdt.core 4 2 Dez 14, 2003 16:28:38.412
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.core".
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.hasFineGrainChanges(TypeHierarchy.java:725)
	at org.eclipse.jdt.internal.core.DeltaProcessor$3.run(DeltaProcessor.java:1408)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.notifyTypeHierarchies(DeltaProcessor.java:1402)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:1820)
	at
org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:226)
	at
org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:251)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:244)
	at
org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:138)
	at
org.eclipse.core.internal.resources.Workspace.broadcastChanges(Workspace.java:146)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:847)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1564)
	at
org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:37)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:62)
!ENTRY org.eclipse.jdt.core 4 4 Dez 14, 2003 16:28:38.432
!MESSAGE Exception occurred in listener of Java element change notification
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.hasFineGrainChanges(TypeHierarchy.java:725)
	at org.eclipse.jdt.internal.core.DeltaProcessor$3.run(DeltaProcessor.java:1408)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.notifyTypeHierarchies(DeltaProcessor.java:1402)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:1820)
	at
org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:226)
	at
org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:251)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:244)
	at
org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:138)
	at
org.eclipse.core.internal.resources.Workspace.broadcastChanges(Workspace.java:146)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:847)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1564)
	at
org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:37)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:62)
!ENTRY org.eclipse.jdt.core 4 2 Dez 14, 2003 16:28:38.503
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.core".
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByOpenable(TypeHierarchy.java:968)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:825)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByPackageFragment(TypeHierarchy.java:907)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:822)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByPackageFragmentRoot(TypeHierarchy.java:957)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:820)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByJavaProject(TypeHierarchy.java:889)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:818)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByJavaModel(TypeHierarchy.java:854)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:816)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.elementChanged(TypeHierarchy.java:347)
	at org.eclipse.jdt.internal.core.DeltaProcessor$2.run(DeltaProcessor.java:1387)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.notifyListeners(DeltaProcessor.java:1382)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.firePostChangeDelta(DeltaProcessor.java:1226)
	at org.eclipse.jdt.internal.core.DeltaProcessor.fire(DeltaProcessor.java:1205)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:1821)
	at
org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:226)
	at
org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:251)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:244)
	at
org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:138)
	at
org.eclipse.core.internal.resources.Workspace.broadcastChanges(Workspace.java:146)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:847)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1564)
	at
org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:37)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:62)
!ENTRY org.eclipse.jdt.core 4 4 Dez 14, 2003 16:28:38.523
!MESSAGE Exception occurred in listener of Java element change notification
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByOpenable(TypeHierarchy.java:968)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:825)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByPackageFragment(TypeHierarchy.java:907)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:822)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByPackageFragmentRoot(TypeHierarchy.java:957)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:820)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByJavaProject(TypeHierarchy.java:889)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:818)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByChildren(TypeHierarchy.java:838)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffectedByJavaModel(TypeHierarchy.java:854)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isAffected(TypeHierarchy.java:816)
	at
org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.elementChanged(TypeHierarchy.java:347)
	at org.eclipse.jdt.internal.core.DeltaProcessor$2.run(DeltaProcessor.java:1387)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.notifyListeners(DeltaProcessor.java:1382)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.firePostChangeDelta(DeltaProcessor.java:1226)
	at org.eclipse.jdt.internal.core.DeltaProcessor.fire(DeltaProcessor.java:1205)
	at
org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:1821)
	at
org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:226)
	at
org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:251)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1127)
	at org.eclipse.core.runtime.Platform.run(Platform.java:464)
	at
org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:244)
	at
org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:138)
	at
org.eclipse.core.internal.resources.Workspace.broadcastChanges(Workspace.java:146)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:847)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1564)
	at
org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:37)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:62)
Comment 1 Dirk Baeumer CLA 2003-12-14 12:39:42 EST
Sebastian,

refactor/move can be aborted/canceled (the button in disabed). Can you please 
explain how you canceled the operation.
Comment 2 Sebastian Davids CLA 2003-12-14 21:40:03 EST
I clicked on Abort.
Comment 3 Sebastian Davids CLA 2003-12-14 22:04:07 EST
Looking at the source code I think it is a threading problem:

protected boolean isAffectedByOpenable(IJavaElementDelta delta, IJavaElement
element) {
	if (element instanceof CompilationUnit) {
		CompilationUnit cu = (CompilationUnit)element;
		ChangeCollector collector = this.changeCollector == null ? new
ChangeCollector(this) : this.changeCollector;
		try {
			collector.addChange(cu, delta); //<------exception thrown here

@@@@

public boolean hasFineGrainChanges() {
	return this.changeCollector != null && this.changeCollector.needsRefresh();
}

@@@@

Seems as if somehow another thread has set changeCollector to null after the
null-check has been made.

In the middle of refresh(IProgressMonitor) changeCollector is set to null.

Probably both methods above have to be synchronized.
Comment 4 Dirk Baeumer CLA 2003-12-15 13:50:59 EST
The only dialog that has an abort button is the one shown when an unexpected 
error was thrown by the refactoring. Can you remember the sort of error that 
was presented. Best would be if you can provide the corresponding stack trace 
from the log.

Regarding your observations: I am not sure that the stack traces are connected 
to the problem you had. So I would first like to reproduce the problem.
Comment 5 Sebastian Davids CLA 2003-12-15 17:53:49 EST
I've looked through the log file ... the stack traces above are the only ones
logged at that particular time.

Unfortunately I don't remember the wording of the dialog.

I tried to reproduce the error w/ the same workspace and repeatedly
moving/importing the file -- I couldn't.

I still think that it is a concurrency problem that's why I cannot reproduce it
"easily" -- problem is I do not know what happened in the background at that time :/
Comment 6 Dirk Baeumer CLA 2003-12-16 17:13:00 EST
All the exceptions happen in JDT/COre code. Philippe can you please comment on 
this and the comment #3.
Comment 7 Philipe Mulet CLA 2003-12-16 18:29:12 EST
Jerome - pls investigate (and adopt if our fault)
Comment 8 Jerome Lanneluc CLA 2003-12-17 06:11:09 EST
First NPE in JavaModelOperation at line 715 can only happen 
if 'deltaProcessor.javaModelDeltas' is null. Howver looking at the write 
accesses to this field, it appears always initialized to a non-null value. It 
sounds like a VM/JIT problem.

Sebastian which VM are you using to run Eclipse?
Comment 9 Sebastian Davids CLA 2003-12-17 06:43:02 EST
Win XP

Sun JRE 1.4.2_02-b03
Java HotSpot 1.4.2_02-b03, mixed mode

single processor
Comment 10 Jerome Lanneluc CLA 2003-12-17 12:38:17 EST
Added protection when accessing 'changeCollector' field (using a local variable 
before checking if it is null)
Comment 11 Sebastian Davids CLA 2003-12-17 14:41:23 EST
fix looks good to me
Comment 12 Jerome Lanneluc CLA 2003-12-18 12:11:52 EST
Verified that the code for the fix is included in I200312180955