Bug 25980 - NullPointerException during Refactor/Move operation
Summary: NullPointerException during Refactor/Move operation
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-11 11:22 EST by David Pickens CLA
Modified: 2003-01-14 06:06 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 David Pickens CLA 2002-11-11 11:22:43 EST
When I attempt to move a class from one package to another (Refactor->Move), 
the following internal error occurs (Version 2.1 M2). This is evidently a 
regression in 2.1 because I've done this operation several times under 2.0.1.

java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread
(ModalContext.java:310)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249)
	at org.eclipse.jface.window.ApplicationWindow$1.run
(ApplicationWindow.java:394)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
	at org.eclipse.jface.window.ApplicationWindow.run
(ApplicationWindow.java:391)
	at org.eclipse.ui.internal.WorkbenchWindow.run
(WorkbenchWindow.java:1194)
	at org.eclipse.jdt.internal.ui.reorg.JdtMoveAction.doReorg
(JdtMoveAction.java:138)
	at org.eclipse.jdt.internal.ui.reorg.ReorgDestinationAction.run
(ReorgDestinationAction.java:106)
	at org.eclipse.jdt.internal.ui.reorg.JdtMoveAction.run
(JdtMoveAction.java:66)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun
(SelectionDispatchAction.java:191)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run
(SelectionDispatchAction.java:169)
	at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:85)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:749)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:407)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent
(ActionContributionItem.java:361)
	at org.eclipse.jface.action.ActionContributionItem.access$0
(ActionContributionItem.java:352)
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java:47)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1622)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1368)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1420)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1403)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:775)
	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:247)
	at org.eclipse.core.launcher.Main.run(Main.java:703)
	at org.eclipse.core.launcher.Main.main(Main.java:539)
Caused by: java.lang.NullPointerException
	at 
org.eclipse.jdt.internal.corext.refactoring.reorg.MoveRefactoring.checkReference
sToNotPublicTypes(MoveRefactoring.java:108)
	at 
org.eclipse.jdt.internal.corext.refactoring.reorg.MoveRefactoring.checkInput
(MoveRefactoring.java:82)
	at 
org.eclipse.jdt.internal.corext.refactoring.base.Refactoring.checkPreconditions
(Refactoring.java:72)
	at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run
(CheckConditionsOperation.java:55)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread
(ModalContext.java:299)
	... 31 more
Comment 1 Adam Kiezun CLA 2002-11-11 11:52:24 EST
hmm, cannot reproduce
can you provide a small test case?
do you select a class or a .java file?
in which view do you perform the action?
from which menu (context or global) do you choose 'move'?
Comment 2 Adam Kiezun CLA 2002-11-11 12:57:02 EST
additional comments from David:

Adam,
I just discovered that the problem also happens in 2.0.1. There must be
something wierd about my project because I have successfully done
this operation a number of times in the past. My project consists of 15 
packages with over 450 java files. So, its doubtful that I'll be able to 
reproduce the problem in a small test case.

The problem occured when I did a context Refactor->Move operation in the
Project View on a .java file.

I brought up 2.0.1 and "imported" the project and the problem persists.

I don't know if this is relavent, but the Java files that I had the error
on are not explicitly referenced. They are instantiated by "Class.forName"

Comment 3 Qian Z. Wang CLA 2002-12-03 21:08:58 EST
I've encountered a similar problem in 2.0.2 on linux (gtk).

I have been able to recreate the bug using the following test case:
1. Create new project.
2. Create 2 new source folders.
3. Create the identical package in each folder A & B.
4. Create new interface I_1 with default access in folder A.
5. Create new interface I_2 extends I_1 with default access in folder A.
6. Refactor -> move (regardless of menu) I_2 from folder A to folder B.
7. This move will succeed.
8. Move I_2 back from B to A will trigger the error (see full trace below).

In this test case, when I_2 is initially moved from A to B, a new 
import package.I_1 will be added to I_2.  If you delete the import, the second
move will succeed.  This is a bit different from the behavior I observed in my
real project where having no import statement still triggers the same bug.

The trace is slightly different, but if you go back far enough in mine you
arrive at ...MoveRefactoring.checkReferencesToNotPublicTypes also.

Full trace:

java.lang.reflect.InvocationTargetException
	at
org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:310)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249)
	at
org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:376)
	at org.eclipse.jdt.internal.ui.reorg.JdtMoveAction.doReorg(JdtMoveAction.java:138)
	at
org.eclipse.jdt.internal.ui.reorg.ReorgDestinationAction.run(ReorgDestinationAction.java:105)
	at org.eclipse.jdt.internal.ui.reorg.JdtMoveAction.run(JdtMoveAction.java:66)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:197)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:175)
	at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:100)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:749)
	at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:407)
	at
org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:361)
	at
org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:352)
	at
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:47)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:826)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1379)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1223)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1343)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1326)
	at
org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:831)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462)
	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:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:248)
	at org.eclipse.core.launcher.Main.run(Main.java:698)
	at org.eclipse.core.launcher.Main.main(Main.java:534)
Caused by: java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.canBeSeenBy(ReferenceBinding.java:177)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:955)
	at
org.eclipse.jdt.internal.core.search.matching.MatchSet.reportMatching(MatchSet.java:222)
	at
org.eclipse.jdt.internal.core.search.matching.MatchingOpenable.locateMatchesInCompilationUnit(MatchingOpenable.java:331)
	at
org.eclipse.jdt.internal.core.search.matching.MatchingOpenable.locateMatches(MatchingOpenable.java:174)
	at
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1323)
	at
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:586)
	at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:412)
	at
org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search(RefactoringSearchEngine.java:131)
	at
org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search(RefactoringSearchEngine.java:98)
	at
org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search(RefactoringSearchEngine.java:93)
	at
org.eclipse.jdt.internal.corext.refactoring.reorg.MoveRefactoring.checkPackageVisibileClassReferences(MoveRefactoring.java:129)
	at
org.eclipse.jdt.internal.corext.refactoring.reorg.MoveRefactoring.checkInput(MoveRefactoring.java:83)
	at
org.eclipse.jdt.internal.corext.refactoring.base.Refactoring.checkPreconditions(Refactoring.java:84)
	at
org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:54)
	at
org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:299)
	... 28 more
Comment 4 Adam Kiezun CLA 2002-12-18 06:47:01 EST
if it's
Caused by: java.lang.NullPointerException
at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.canBeSeenBy(ReferenceBinding.java:177)
at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:955)

then it'd be a jcore problem

Comment 5 Jerome Lanneluc CLA 2003-01-14 06:06:08 EST
Verified this works with code in HEAD.
Closing (please reopen if you see the problem in build 20030114 or later)