Bug 3759 - ResourceException, JavaModelException: Packages (1GEO05E)
Summary: ResourceException, JavaModelException: Packages (1GEO05E)
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All Windows 2000
: P2 critical (vote)
Target Milestone: ---   Edit
Assignee: Erich Gamma CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 23:00 EDT by Erich Gamma CLA
Modified: 2002-03-08 05:18 EST (History)
1 user (show)

See Also:


Attachments
Bad error dialog (38.87 KB, image/jpeg)
2002-02-27 06:19 EST, Dani Megert CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Gamma CLA 2001-10-10 23:00:25 EDT
The core team is already aware of the case sensitivity issue, but the point of this PR is that the Packages view
doesn't handle the same Exceptions that the Navigator view does.

1. Create a package named "Pack" and a class named "Main.java"
2. In the Packages view, rename Main.java into "main.java"
	Resource Exception is thrown.
3. In the Packages view, rename Pack into "pack"
	JavaModelException is thrown and the "pack" package is created.

Log: Fri Jun 01 19:31:50 EDT 2001
4 org.eclipse.jdt.ui 566 Internal Error
org.eclipse.core.internal.resources.ResourceException: Resource already exists on disk: D:\eclipse\workspace\BrandNew\Pack\main.java.
	at org.eclipse.core.internal.localstore.FileSystemStore.move(FileSystemStore.java:109)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.move(FileSystemResourceManager.java:166)
	at org.eclipse.core.internal.resources.Resource.moveInFileSystem(Resource.java:841)
	at org.eclipse.core.internal.resources.Resource.move(Resource.java:799)
	at org.eclipse.core.internal.resources.Resource.move(Resource.java:769)
	at org.eclipse.jdt.internal.core.refactoring.RenameResourceChange.perform(RenameResourceChange.java:57)
	at org.eclipse.jdt.internal.core.refactoring.CompositeChange.createUndoList(CompositeChange.java:107)
	at org.eclipse.jdt.internal.core.refactoring.CompositeChange.perform(CompositeChange.java:132)
	at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation$1.execute(PerformChangeOperation.java:143)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:64)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1121)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:78)
	at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:148)
	at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:124)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249)
	at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:714)
	at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:285)
	at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:147)
	at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:409)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:571)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:313)
	at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:210)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code))
	at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code))
	at org.eclipse.jface.window.Window.open(Window.java:520)
	at org.eclipse.jdt.internal.ui.reorg.RefactoringSupportFactory$RenameSupport.rename(RefactoringSupportFactory.java:55)
	at org.eclipse.jdt.internal.ui.reorg.RenameAction.doActionPerformed(RenameAction.java:77)
	at org.eclipse.jdt.internal.ui.reorg.ReorgAction.run(ReorgAction.java:51)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:408)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java(Compiled Code))
	at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code))
	at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:602)
	at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:820)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:70)
	at org.eclipse.core.launcher.Main.run(Main.java:363)
	at org.eclipse.core.launcher.Main.main(Main.java:240)
Log: Fri Jun 01 19:32:02 EDT 2001
4 org.eclipse.jdt.ui 566 Internal Error
org.eclipse.jdt.core.JavaModelException[966]: org.eclipse.core.internal.resources.ResourceException: Resource /BrandNew/pack must not exist.
	at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:148)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:61)
	at org.eclipse.jdt.internal.core.JavaModelOperation.createFolder(JavaModelOperation.java:186)
	at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.createNeededPackageFragments(CopyResourceElementsOperation.java:132)
	at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processPackageFragmentResource(CopyResourceElementsOperation.java:302)
	at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processElement(CopyResourceElementsOperation.java:266)
	at org.eclipse.jdt.internal.core.MultiOperation.processElements(MultiOperation.java:182)
	at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processElements(CopyResourceElementsOperation.java:280)
	at org.eclipse.jdt.internal.core.MultiOperation.executeOperation(MultiOperation.java:86)
	at org.eclipse.jdt.internal.core.JavaModelOperation.execute(JavaModelOperation.java:257)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:452)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1121)
	at org.eclipse.jdt.internal.core.JavaModelManager.runOperation(JavaModelManager.java:1004)
	at org.eclipse.jdt.internal.core.JavaElement.runOperation(JavaElement.java:508)
	at org.eclipse.jdt.internal.core.JavaModel.rename(JavaModel.java:484)
	at org.eclipse.jdt.internal.core.PackageFragment.rename(PackageFragment.java:288)
	at org.eclipse.jdt.core.refactoring.packages.RenamePackageChange.perform(RenamePackageChange.java:84)
	at org.eclipse.jdt.internal.core.refactoring.CompositeChange.createUndoList(CompositeChange.java:107)
	at org.eclipse.jdt.internal.core.refactoring.CompositeChange.perform(CompositeChange.java:132)
	at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation$1.execute(PerformChangeOperation.java:143)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:64)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1121)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:78)
	at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:148)
	at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:124)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249)
	at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:714)
	at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:285)
	at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:147)
	at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:409)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:571)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:313)
	at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:210)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code))
	at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code))
	at org.eclipse.jface.window.Window.open(Window.java:520)
	at org.eclipse.jdt.internal.ui.reorg.RefactoringSupportFactory$RenameSupport.rename(RefactoringSupportFactory.java:55)
	at org.eclipse.jdt.internal.ui.reorg.RenameAction.doActionPerformed(RenameAction.java:77)
	at org.eclipse.jdt.internal.ui.reorg.ReorgAction.run(ReorgAction.java:51)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:408)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java(Compiled Code))
	at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code))
	at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:602)
	at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:820)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:70)
	at org.eclipse.core.launcher.Main.run(Main.java:363)
	at org.eclipse.core.launcher.Main.main(Main.java:240)


NOTES:

	KH (6/2/2001 10:55:05 AM)
		Moving to JUI
Comment 1 Martin Aeschlimann CLA 2001-10-16 11:13:29 EDT
moved to 'active'
Comment 2 DJ Houghton CLA 2001-10-24 07:19:22 EDT
PRODUCT VERSION:
116 JDK
Windows 2000

Comment 3 Adam Kiezun CLA 2001-10-31 11:49:06 EST
2. works for me now (206)
4. rename calls getPackageFragment(String) on IPackageFragmentRoot
this method returns a not existing package, so it's assumed that the package
'pack' does not exist

moving to jcore
Comment 4 Philipe Mulet CLA 2001-11-14 04:22:31 EST
Unfortunately, this is an API and we have to live with it.
Need to tune the spec to better clarify this situation.
Comment 5 Philipe Mulet CLA 2002-02-12 08:01:01 EST
As said in previous post, this API is spec'ed to NOT perform any existency 
check, it has to be explicitly done in UI code.

	/**
	 * Returns the package fragment with the given package name.
	 * An empty string indicates the default package.
	 * This is a handle-only operation.  The package fragment
	 * may or may not exist.
	 */

Back to UI
Comment 6 Erich Gamma CLA 2002-02-12 08:21:56 EST
makes sense to me that the UI should catch JavaModel exceptions on a handle 
only method. Adam is there any reason why can't handle this exception?
Comment 7 Adam Kiezun CLA 2002-02-15 09:13:58 EST
from a IPackageFragmentRoot i get a IPackageFragment
i ask exists() and it returns false

so i think it is reasonable for me to conclude that it is safe to create 
a package with that name.

note that on the core (resource) level the same problem exists - core simply
says that everything is just fine until you try creating/renaming resources.

then, an exception is thrown that indicates a problem that you have just been 
promised would not happen!

the ui is the worst place to work-around these kinds of problems.
this should be solved either on the core or jcore level
Comment 8 Dani Megert CLA 2002-02-27 06:17:54 EST
Test case 1 now works but test case 2 fails with cryptic message (see attached
picture).

==> so if neither J Core nor UI thinks its their bug then at least show a
message which the user can understand.
Comment 9 Dani Megert CLA 2002-02-27 06:19:17 EST
Created attachment 400 [details]
Bad error dialog
Comment 10 Adam Kiezun CLA 2002-03-07 08:54:46 EST
i fixed the error message
and i put an explicit check for the rename package case 
(check if you're renaming only changing case and disallowing it)

it's a workaround - not a fix really.
the real fix should come from the lower layers - ui needs a query for this case.
back to inbox for re-directing or closing
Comment 11 Erich Gamma CLA 2002-03-08 05:18:05 EST
closing