Community
Participate
Working Groups
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
moved to 'active'
PRODUCT VERSION: 116 JDK Windows 2000
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
Unfortunately, this is an API and we have to live with it. Need to tune the spec to better clarify this situation.
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
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?
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
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.
Created attachment 400 [details] Bad error dialog
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
closing