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

Bug 547485

Summary: IllegalArgumentException using placeholder in model fragments
Product: [Eclipse Project] Platform Reporter: Simon Scholz <simon.scholz>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: critical    
Priority: P3 CC: eclipse, Lars.Vogel, loskutov, rolf.theunissen
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=547503
https://bugs.eclipse.org/bugs/show_bug.cgi?id=487748
Whiteboard: stalebug
Attachments:
Description Flags
Sample e4 application to reproduce the error none

Description Simon Scholz CLA 2019-05-20 10:07:57 EDT
Created attachment 278667 [details]
Sample e4 application to reproduce the error

Hi,

I've attached a sample application, which can be started by using the product inside the brokenmodel project.

Steps to reproduce.

1) Start the application by using the product
2) Close the application (causes save of a workbench.xmi file)
3) Restart the application (without -clearPersistedState flag -> loads workbench.xmi)
4) Click on "Shared Part" tab

These steps cause the following error:

!MESSAGE Internal Error
!STACK 0
java.lang.IllegalArgumentException: 
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:66)
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:50)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.findElementsRecursive(ModelServiceImpl.java:175)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.findPerspectiveElements(ModelServiceImpl.java:438)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.findPlaceholderFor(ModelServiceImpl.java:661)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:624)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:616)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:791)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:762)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:684)
	at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.lambda$3(StackRenderer.java:1058)
	at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:84)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5874)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1400)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1426)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1409)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1198)
	at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3193)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1876)
	at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:330)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5874)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1400)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5138)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4663)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:166)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:661)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1476)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1449)
Comment 1 Andrey Loskutov CLA 2019-05-20 10:10:09 EDT
Simon, is this a regression in 4.12?
Comment 2 Simon Scholz CLA 2019-05-20 10:17:33 EDT
The actual problem, which causes this IllegalArgumentException is that the shared element part is inside a org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl container instead of being merged into to actual application model tree.
Therefore the org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.getTopLevelWindowFor(MUIElement) method returns null and causes this error.

I don't know why the container of the shared part is still a StringModelFragmentImpl rather than the window where it belongs to at runtime.
Comment 3 Simon Scholz CLA 2019-05-20 10:20:07 EDT
(In reply to Andrey Loskutov from comment #1)
> Simon, is this a regression in 4.12?

No, unfortunately it's not that easy. We tested it with the current release and even tested it with Eclipse 4.6 and also with an integration build from last week.
Comment 4 Lars Vogel CLA 2019-05-21 05:58:41 EDT
Simon, looks like your runtime model contains elements without parents. Would be good to know if the save model is wrong or the loaded model.

Can you add a test to ModelAssemblerTests to checks this?
Comment 5 Rolf Theunissen CLA 2019-05-31 04:48:39 EDT
The error does not occur in the following cases:
1. When the fragment is only applied when it not exists, apply="notexists" in plugin.xml
2. When the view was active when the window is closed.

Especially option 1 makes me believe that the error is caused by re-applying the snippet to the model.
Comment 6 Rolf Theunissen CLA 2019-06-01 16:48:28 EDT
Probably a duplicate of Bug 487748
Comment 7 Rolf Theunissen CLA 2019-06-01 17:08:17 EDT
(In reply to Rolf Theunissen from comment #6)
> Probably a duplicate of Bug 487748

And Bug 487748 is a duplicate of Bug 440030
Comment 8 Eclipse Genie CLA 2021-05-22 10:19:09 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.