`ClassCastException` with Eclipse RCP Internals on 2022-12

121 views Asked by At

I am currently responsible for upgrading a legacy Eclipse RCP application at my job from Java 11 to Java 17. As part of this, I am upgrading from Eclipse 2018-12 to 2022-12.

However, this has introduced a runtime ClassCastException that I cannot seem to chase down. Specifically:

org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException: class org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl cannot be cast to class org.eclipse.e4.ui.model.application.ui.menu.MToolControl (org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl and org.eclipse.e4.ui.model.application.ui.menu.MToolControl are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @5a5e548c)
        at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:68)
        at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:183)
        at org.eclipse.swt.widgets.Display.syncExec(Display.java:5960)
        at org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize.syncExec(DisplayUISynchronize.java:34)
        at org.eclipse.e4.ui.internal.di.UIEventObjectSupplier$UIEventHandler.handleEvent(UIEventObjectSupplier.java:64)
        at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
        at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
        at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
        at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:133)
        at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
        at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
        at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
        at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
        at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
        at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
        at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:304)
        at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:304)
        at org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon.setState(MinMaxAddon.java:210)
        at org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon$1.minimize(MinMaxAddon.java:129)
        at org.eclipse.swt.custom.CTabFolder.onSelection(CTabFolder.java:2171)
        at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:341)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5855)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1529)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5065)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4517)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:168)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
Caused by: java.lang.ClassCastException: class org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl cannot be cast to class org.eclipse.e4.ui.model.application.ui.menu.MToolControl (org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl and org.eclipse.e4.ui.model.application.ui.menu.MToolControl are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @5a5e548c)
        at org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon.createTrim(MinMaxAddon.java:1019)
        at org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon.minimize(MinMaxAddon.java:666)
        at org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon.subscribeTopicTagsChanged(MinMaxAddon.java:407)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
        ... 45 more

This occurs when I try to interact with these minimize and maximize buttons on the right of panel headers:

Eclipse RCP Panel Header

PartStackImpl and MToolControl are both part of the org.eclipse.e4.ui.model.workbench jarfile, while MinMaxAddon (which is attempting the cast) is part of org.eclipse.e4.workbench.addons.swt. I've confirmed that both of these jarfiles are their most up-to-date versions available for 2022-12 (2.2.300 and 1.4.500 respectively, both from Oct. 2022).

Inspecting the inheritance tree for PartStackImpl confirms that it is indeed not a subtype of MToolControl, so the class cast exception makes sense. However, I am confused as to why the supposedly up-to-date MinMaxAddon is attempting this cast in the first place.

I have next to no experience with Eclipse RCP (the only developer who did here has long since departed), so I'm not sure if I am just missing something specific to the RCP tooling that would be obvious to someone else.

0

There are 0 answers