Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 261641

Summary: failed to open editor for a class file when activating task
Product: z_Archived Reporter: Tomasz Zarna <tomasz.zarna>
Component: MylynAssignee: Project Inbox <mylyn-triaged>
Status: CLOSED MOVED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, shawn.minto, steffen.pingel
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tomasz Zarna CLA 2009-01-20 09:03:04 EST
I20090113-0918

All editors were restored by Mylyn if this matters. When switching to one of them I got the following exception:

org.eclipse.ui.PartInitException: Factory org.eclipse.jdt.ui.ClassFileEditorInputFactory returned null from createElement for editor id=org.eclipse.jdt.ui.ClassFileEditor name=TextViewer.class
	at org.eclipse.ui.internal.EditorReference.getRestoredInput(EditorReference.java:383)
	at org.eclipse.ui.internal.EditorReference.getEditorInput(EditorReference.java:344)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:607)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:444)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1209)
	at org.eclipse.ui.internal.PartStack.presentationSelectionChanged(PartStack.java:843)
	at org.eclipse.ui.internal.PartStack.access$1(PartStack.java:829)
	at org.eclipse.ui.internal.PartStack$1.selectPart(PartStack.java:139)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:133)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:267)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:276)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$2.handleEvent(DefaultTabFolder.java:87)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:770)
	at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3259)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:2034)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:324)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3875)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3470)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:333)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
	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:194)
	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:366)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	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.equinox.launcher.Main.invokeFramework(Main.java:550)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:505)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1237)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1213)
Comment 1 Tomasz Zarna CLA 2009-01-20 09:07:04 EST
This happens to most of the class files Mylyn opened but not for all of them. Maybe the fact that I used Mylyn context created in a different workspace is crucial here. Not sure if this is a JDT issue then...
Comment 2 Dani Megert CLA 2009-01-20 09:42:16 EST
>This happens to most of the class files Mylyn opened
How is Mylyn exactly involved? I cannot see this in the stack trace.

Restoring editors work for me unless of course you changed the target platform in a way that required bundles could no longer be resolved.

For improving the .log message see bug 240453.
Comment 3 Dani Megert CLA 2009-01-21 05:12:37 EST
Tomasz, can you answer the questions? Thanks.
Comment 4 Tomasz Zarna CLA 2009-01-21 08:52:04 EST
(In reply to comment #2)
> >This happens to most of the class files Mylyn opened
> How is Mylyn exactly involved? I cannot see this in the stack trace.

It manages which editors are to be restored on a task activation. But I assume Mylyn does nothing special when reopening the editors, that was just a guess.

> Restoring editors work for me unless of course you changed the target platform
> in a way that required bundles could no longer be resolved.

Does it mean that if I have opened TextViewer.class file from a bundle, closed the Eclipse and then open the same workspace but using a different Eclipse build the editor won't open the class file since the org.eclipse.jface.text bundle versions are different?

> For improving the .log message see bug 240453.

Haven't seen the exception since.

Sorry for the late response.


Comment 5 Dani Megert CLA 2009-01-21 09:18:21 EST
>It manages which editors are to be restored on a task activation.
What exactly did you do?

>Does it mean that if I have opened TextViewer.class file from a bundle, closed
>the Eclipse and then open the same workspace but using a different Eclipse
>build the editor won't open the class file since the org.eclipse.jface.text
>bundle versions are different?
No, in general that works but plug-ins can change their shapes. Types might be moved to another plug-in or disappear completely and hence it might not be able to restore them.
Comment 6 Dani Megert CLA 2009-01-21 10:25:19 EST
Moving to Mylyn for a closer look. We haven't seen this with plain Eclipse SDK.
Comment 7 Steffen Pingel CLA 2009-01-21 14:08:54 EST
I believe you can reproduce the exception if the editor memento for a class file in a bundle had source code attached and when the memento is restored does not have source code attached anymore (or the other way around). This might be difficult to reproduce without Mylyn since editors are only restored when the workbench is restarted so changing the source attachment of a bundle in between save and restore of the memento is not as easy.
Comment 8 Dani Megert CLA 2009-01-22 02:29:09 EST
>I believe you can reproduce the exception if the editor memento for a class
>file in a bundle had source code attached and when the memento is restored does
>not have source code attached anymore (or the other way around).
Sorry but this is wrong. The only reason where this can happen is if the class is not found, e.g. because a required bundle was not correctly resolved and the class is missing or because someone tries to restore class file editors before JDT is initialized.
Comment 9 Tomasz Zarna CLA 2009-01-22 06:03:49 EST
(In reply to comment #7)
> I believe you can reproduce the exception if the editor memento for a class
> file in a bundle had source code attached and when the memento is restored does
> not have source code attached anymore (or the other way around).

Yep, a similar thing happen to me again. I worked on a task, opened a class file with source code attached, deactivated the task, checkout the project from CVS (to get proper, latest source), activated the task again. The stack trace is a little bit different though:

org.eclipse.core.runtime.CoreException: The Class File Viewer cannot handle the given input ('org.eclipse.ui.part.FileEditorInput').
	at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput(ClassFileEditor.java:644)
	at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3074)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:458)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:366)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2577)
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3092)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3119)
	at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:802)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:660)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:444)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1209)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1608)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
	at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
	at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
	at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
	at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:782)
	at org.eclipse.ui.internal.EditorManager.access$0(EditorManager.java:779)
	at org.eclipse.ui.internal.EditorManager$7.runWithException(EditorManager.java:1482)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:178)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4307)
	at org.eclipse.ui.internal.StartupThreading.runWithPartInitExceptions(StartupThreading.java:68)
	at org.eclipse.ui.internal.EditorManager.restoreEditorState(EditorManager.java:1479)
	at org.eclipse.mylyn.internal.context.ui.ContextEditorManager.restoreEditors(ContextEditorManager.java:296)
	at org.eclipse.mylyn.internal.context.ui.ContextEditorManager.contextActivated(ContextEditorManager.java:115)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.internalActivateContext(InteractionContextManager.java:593)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.activateContext(InteractionContextManager.java:163)
	at org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin$1.taskActivated(TasksUiPlugin.java:244)
	at org.eclipse.mylyn.internal.tasks.core.TaskActivityManager.activateTask(TaskActivityManager.java:413)
	at org.eclipse.mylyn.internal.tasks.ui.actions.TaskActivateAction.run(TaskActivateAction.java:48)
	at org.eclipse.mylyn.internal.tasks.ui.views.TaskListCellModifier.toggleTaskActivation(TaskListCellModifier.java:130)
	at org.eclipse.mylyn.internal.tasks.ui.views.TaskListView$9.mouseDown(TaskListView.java:930)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3875)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3470)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2388)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2352)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2204)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:499)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:333)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:492)
	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:194)
	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:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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.equinox.launcher.Main.invokeFramework(Main.java:550)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:505)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1237)


Comment 10 Dani Megert CLA 2009-01-22 06:14:31 EST
I see. So this seems to happen when someone tries to restore an editor of wrong type e.g. class file editor was open and stored. Then source got loaded (not attached!) hence the class file is no longer there. Trying to restore the class file editor therefore obviously fails (and the other way around of course).
Comment 11 Steffen Pingel CLA 2011-04-05 14:48:52 EDT
I'll add this to the backlog. We can consider improvements to editor restore for e4 but it's unlikely that we'll fix this for 3.x unless this is addressed in JDT.
Comment 12 Eclipse Webmaster CLA 2022-11-15 11:45:08 EST
Mylyn has been restructured, and our issue tracking has moved to GitHub [1].

We are closing ~14K Bugzilla issues to give the new team a fresh start. If you feel that this issue is still relevant, please create a new one on GitHub.

[1] https://github.com/orgs/eclipse-mylyn