Community
Participate
Working Groups
I am splittin on java project into 3 smaller projects. Several moves of packages and classes worked well. Moving one class caused this java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding (see full stacktrace below). It doesn't look like somthing special on the interface I tried to move. So I tried the same Operation on Windows and Linux with a fresh Eclipse installation. Same Error. I looked at ehe jdt source line 573 of TypeReferenceLocator caused the Exception ... ClassScope scope = ((SourceTypeBinding) typeBinding).scope; if (scope != null) { ... The next line checks that scope is not null. I tried an instanceof check for the object typeBinding, at line 573 and fellows, like: ... ClassScope scope = null; if(typeBinding instanceof SourceTypeBinding ) scope = ((SourceTypeBinding) typeBinding).scope; .. With this small path the refactoring operation works. -- Error Details -- Date: Wed Jul 23 17:35:44 CEST 2008 Message: Internal Error Severity: Error Plugin: org.eclipse.ltk.ui.refactoring Session Data: eclipse.buildId=I20080617-2000 java.version=1.6.0_06 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US Framework arguments: -product org.eclipse.sdk.ide Command-line arguments: -product org.eclipse.sdk.ide -data /home/kpanier/projects/sig/bsw_osgi -dev file:/home/kpanier/projects/eclipse-debug/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os linux -ws gtk -arch x86 -console -consolelog Exception Stack Trace: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:403) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:317) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:558) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:154) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveWizard$MoveInputPage.performFinish(ReorgMoveWizard.java:109) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:622) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:446) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:472) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1158) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3401) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3033) at org.eclipse.jface.window.Window.runEventLoop(Window.java:825) at org.eclipse.jface.window.Window.open(Window.java:801) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:144) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:156) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:37) at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startMoveRefactoring(RefactoringExecutionStarter.java:394) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:107) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250) at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:143) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1158) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3401) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3033) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 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:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212) Caused by: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.reportDeclaration(TypeReferenceLocator.java:573) at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.reportDeclaration(TypeReferenceLocator.java:552) at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.matchReportReference(TypeReferenceLocator.java:309) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2147) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2593) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2322) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1614) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1040) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1081) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1213) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarations(BasicSearchEngine.java:1174) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarationsOfReferencedTypes(BasicSearchEngine.java:1249) at org.eclipse.jdt.core.search.SearchEngine.searchDeclarationsOfReferencedTypes(SearchEngine.java:1173) at org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getTypeReferencesIn(ReferenceFinderUtil.java:72) at org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getTypeReferencesIn(ReferenceFinderUtil.java:63) at org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getTypesReferencedIn(ReferenceFinderUtil.java:48) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.addImportToSourcePackageTypes(MoveCuUpdateCreator.java:244) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.addUpdates(MoveCuUpdateCreator.java:139) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.addUpdates(MoveCuUpdateCreator.java:125) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.createChangeManager(MoveCuUpdateCreator.java:96) at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory$MoveFilesFoldersAndCusPolicy.createChangeManager(ReorgPolicyFactory.java:1292) at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory$MoveFilesFoldersAndCusPolicy.checkFinalConditions(ReorgPolicyFactory.java:1202) at org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor.checkFinalConditions(JavaMoveProcessor.java:93) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:225) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:85) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:211) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Root exception: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.reportDeclaration(TypeReferenceLocator.java:573) at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.reportDeclaration(TypeReferenceLocator.java:552) at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.matchReportReference(TypeReferenceLocator.java:309) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2147) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2593) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2322) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1614) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1040) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1081) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1213) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarations(BasicSearchEngine.java:1174) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarationsOfReferencedTypes(BasicSearchEngine.java:1249) at org.eclipse.jdt.core.search.SearchEngine.searchDeclarationsOfReferencedTypes(SearchEngine.java:1173) at org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getTypeReferencesIn(ReferenceFinderUtil.java:72) at org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getTypeReferencesIn(ReferenceFinderUtil.java:63) at org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getTypesReferencedIn(ReferenceFinderUtil.java:48) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.addImportToSourcePackageTypes(MoveCuUpdateCreator.java:244) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.addUpdates(MoveCuUpdateCreator.java:139) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.addUpdates(MoveCuUpdateCreator.java:125) at org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.createChangeManager(MoveCuUpdateCreator.java:96) at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory$MoveFilesFoldersAndCusPolicy.createChangeManager(ReorgPolicyFactory.java:1292) at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory$MoveFilesFoldersAndCusPolicy.checkFinalConditions(ReorgPolicyFactory.java:1202) at org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor.checkFinalConditions(JavaMoveProcessor.java:93) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:225) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:85) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:211) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Would it be possible to zip the project you were splitting? If not can you try to reduce it to a small project to help me to reproduce this exception? Of course the change you did help the refactoring to pass but it could be only a workaround and we definitely prefer find the origin of the problem to be sure that the fix shouldn't be located elsewhere... Thanks in advance
The project to split is property of the company I work for. So I can't zip it. I'll try to reproduce the problem with a similar Project structure and attach it to this bug.
I am getting a similar issue that might be related. When attempting to extract a class consisting of data members using refactor, I get this class cast exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:403) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:317) ... snip ... Caused by: java.lang.ClassCastException: org.eclipse.jdt.internal.core.search.matching.OrPattern cannot be cast to org.eclipse.jdt.internal.core.search.matching.VariablePattern at org.eclipse.jdt.internal.core.search.matching.MatchLocator.newFieldReferenceMatch(MatchLocator.java:1409) ... snip ... Could this be the same problem? Should I post the whole stack?
(In reply to comment #3) > > Could this be the same problem? Should I post the whole stack? > No, this sounds like a different issue. Please open a new bug providing the full stack trace and a as simple test case as possible to help me to reproduce. Thanks
*** Bug 336028 has been marked as a duplicate of this bug. ***
*** Bug 352934 has been marked as a duplicate of this bug. ***
(In reply to comment #6) > *** Bug 352934 has been marked as a duplicate of this bug. *** Hi. I just encountered the same issue today. I cannot move some classes to a different package. Neither a restart nor a deletion and reimport of this classes solves the issue. The only way to move those classes is on file-system but the error will occur again. After some testing it occurs that a @link ... in javadoc produces this error. Say I have a class Foo in org.test.foobar that is copied from another Class org.other.Foo that contains a {@link org.other.Foo}. So the copied class contains a @link to the old class.(see below for a scratch of the old and new class) Then moving the org.test.foobar.Foo causes the strange error. After removing the link to nowhere everything works fine. This seems to fit to the "MissingType..." thingy in the stacktrace. I hope that helps. Best regards, Florian Quadt The src-folder is under svn control and I am using mylyn.eclipse.buildId=I20110613-1736 ---------------------------------------------- class that is copied: package org.other; /** *{@link org.other.Foo} */ class Foo { } class that produces error: package org.test.foobar; /** *{@link org.other.Foo} */ class Foo { }
(In reply to comment #7) Thanks for the detailed steps. I am able to reproduce the problem now. Simplifying the testcase. #### package org.test.foobar; /** *{@link org.missing.Foo} */ class Foo { } #### 1. Copy/paste this class 2. Make sure that javadoc is processed. 3. Move this class to another package. one should see the error.
Created attachment 204192 [details] Patch + test
Released the fix on master Commit id: 6ed1cf547d485640f7cc1b111de3d2b3735f006a
Raised a follow up bug /361869 for some weird behaviour. Verified that no exception is thrown, using build N20111022-2000.