Community
Participate
Working Groups
Tried to rename a class which was moved to a new package and is used by the project and it's seperated JUnit project. I tested the other class moved to the same project. Its rename action also fails. Outside the package I can rename properly. I will try to do renaming by adding a new class and erase the old one. If I learn something new, I will report back. Thanks for the greate IDE. Martin <-- Log snippet --> !SESSION Apr 15, 2003 09:36:33.843 --------------------------------------------- java.version=1.4.1_02 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE Command-line arguments: -os win32 -ws win32 -arch x86 -mx256m -ms64m -install file:C:/eclipse/ !ENTRY org.eclipse.jdt.ui 4 10001 Apr 15, 2003 09:36:33.843 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:313) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:266) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactorin g(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:363) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:426) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:383) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:256) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:70) at org.eclipse.jdt.internal.ui.refactoring.RefactoringSupport$AbstractRenameSupport .rename(RefactoringSupport.java:168) at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog (RenameSupport.java:98) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run (RenameJavaElementAction.java:147) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run (RenameJavaElementAction.java:76) at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:116) 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.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583) Caused by: java.lang.ClassCastException at org.eclipse.jdt.internal.core.search.matching.TypeReferencePattern.matchReportRe ference(TypeReferencePattern.java:230) at org.eclipse.jdt.internal.core.search.matching.TypeReferencePattern.matchReportRe ference(TypeReferencePattern.java:205) at org.eclipse.jdt.internal.core.search.matching.MatchLocator2.reportReference (MatchLocator2.java:1310) at org.eclipse.jdt.internal.core.search.matching.MatchingNodeSet.reportMatching (MatchingNodeSet.java:240) at org.eclipse.jdt.internal.core.search.matching.MatchingNodeSet.reportMatching (MatchingNodeSet.java:448) at org.eclipse.jdt.internal.core.search.matching.MatchingNodeSet.reportMatching (MatchingNodeSet.java:346) at org.eclipse.jdt.internal.core.search.matching.MatchLocator2.process (MatchLocator2.java:978) at org.eclipse.jdt.internal.core.search.matching.MatchLocator2.locateMatches (MatchLocator2.java:677) at org.eclipse.jdt.internal.core.search.matching.MatchLocator2.locateMatches (MatchLocator2.java:635) at org.eclipse.jdt.internal.core.search.matching.MatchLocator2.locateMatches (MatchLocator2.java:851) at org.eclipse.jdt.core.search.SearchEngine.search (SearchEngine.java:471) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search (RefactoringSearchEngine.java:139) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search (RefactoringSearchEngine.java:106) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search (RefactoringSearchEngine.java:101) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeRefactoring.getRefe rences(RenameTypeRefactoring.java:507) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeRefactoring.checkIn put(RenameTypeRefactoring.java:368) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) ... 44 more
Please provide reproduceable steps for further investigation
After solving some errors in other classes which occured during movement, I can rename all classes. Therefor I changed the severity to normal because It didn't gave me a big headache. Thanks again, Martin
Well I don't know how to reproduce it. Maybe it helps to describe what I have done. Projects: normal - Containing code. normal.test - Containing JUnit tests, uses exactly the same package structure as normal. Class: Cache - Implements a guarded cache. Cache.Key - Implements a simple Key class to hide that from callers Aspect - Particular Aspect of database informations using the Cache (was extracted from their for better reuse). TestClasses: TestCache TestCacheKey TestAspect First of all after extracting the Cache from Aspect I rerun the test suite, everything fine. Then after realising that Cache.Key (private class of cache) is used by Aspect and TestAspect I decided to create package *.cache and move the Cache class to it. The TestCache and TestCacheKey were also moved to a package *.cache within the test project. Problem was Cache.Key is package level so I excluded it from Cache class and tried to rename it in order to introduce other Key types. That was when the error occured. I think that the problem may be caused by a non-exsisting Cache.Key class but everyone referred to it. And then trying to rename a class Key had blown up the scene. Renaming Cache class also produced the same error footprint. Solution: Created a new Class with the new key name. Deleting the Key class, and moving its content to the new class, correcting all the bad references allowed me to rename the class Cache. I will try to reproduce the error again to ease your work.
looks like a problem in org.eclipse.jdt.internal.core.search.matching. TypeReferencePattern - moving to jcore
Got the cause: Having the following situation will cause the problem. Same project: package pack1: class A package pack1.sub: class B class C Adding a cast to a method of class A: ((B.C)new Object()).hashCode(); Then trying to rename B or C will fail producing the error and either B nor C can be renamed but deleted. Sharper Version: as above but without C (only having A and B) again add a cast of B to A like: (NonExsisting.B); Again rename of B, will fail. Other more weird try: Add ((Unknown.Key)new Object()).hashCode(); to a class of any package. Even if the class does not import Key or the package of Key or any other class from its package, renaming Key will fail. But only adding lines like Unknown.Key a; will do nothing. So it seams to doing a cast and using a method of the casted instance will cause an error while renaming a class named the same like the non exsisting inherited class of an non-exsisting class. Hope that helped. Martin
Thanks for the test cases Martin. Fixed TypeReferencePattern.matchReportReference(QualifiedNameReference, ...) to check for the case of a ProblemBinding. Made the same change to DeclarationOfReferencedTypesPattern.matchReportReference (AstNode, ...) and PackageReferencePattern.matchLevel and matchReportReference. Added regression test JavaSearchTests.testTypeReferenceWithProblem()
*** Bug 41821 has been marked as a duplicate of this bug. ***
Verified.