Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException in EcoreEList.set when using notexists in fragment #1721

Open
gdany95 opened this issue Feb 27, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@gdany95
Copy link

gdany95 commented Feb 27, 2024

java.lang.ClassCastException: class org.eclipse.e4.ui.model.application.commands.impl.BindingContextImpl cannot be cast to class java.util.List (org.eclipse.e4.ui.model.application.commands.impl.BindingContextImpl is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @487cb74a; java.util.List is in module java.base of loader 'bootstrap')
	at org.eclipse.emf.ecore.util.EcoreEList.set(EcoreEList.java:457)
	at org.eclipse.e4.ui.model.internal.ModelUtils.mergeList(ModelUtils.java:190)
	at org.eclipse.e4.ui.model.internal.ModelUtils.merge(ModelUtils.java:152)
	at org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl.mergeIdList(StringModelFragmentImpl.java:345)
	at org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl.merge(StringModelFragmentImpl.java:323)
	at ro.linic.ui.base.eclipse.fixes.ModelAssembler.processModelFragment(ModelAssembler.java:640)
	at ro.linic.ui.base.eclipse.fixes.ModelAssembler.processFragment(ModelAssembler.java:529)
	at ro.linic.ui.base.eclipse.fixes.ModelAssembler.processFragments(ModelAssembler.java:489)
	at ro.linic.ui.base.eclipse.fixes.ModelAssembler.processFragmentWrappers(ModelAssembler.java:459)
	at ro.linic.ui.base.eclipse.fixes.ModelAssembler.processFragments(ModelAssembler.java:386)
	at ro.linic.ui.base.eclipse.fixes.ModelAssembler.processModel(ModelAssembler.java:331)
	at ro.linic.ui.base.eclipse.fixes.ResourceHandler.loadMostRecentModel(ResourceHandler.java:187)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:371)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:247)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:155)

I get the exception above when using notexists flag for a fragment. The problem seems to be in EcoreEList.set where the parameter is cast to a list, but in ModelUtils.mergeList we can see that the element is an instance of MApplicationElement, not a list. In ModelUtils.mergeList line 190 the setting is an instance of EObjectResolvingEList.

Note: ro.linic.ui.base.eclipse.fixes.ModelAssembler is just a copy of org.eclipse.e4.ui.internal.workbench.ModelAssembler.

Note: Applying the fix from https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/144622/4/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelAssembler.java meaning removing the existing elements from the fragment before merging seems to fix this exception.

@gdany95 gdany95 added the bug Something isn't working label Feb 27, 2024
@merks
Copy link
Contributor

merks commented Feb 28, 2024

I suspect no one will try to fix this for you. It's pretty easy to set up an IDE with the sources such that you can create a pull request:

https://github.com/eclipse-platform/.github/blob/main/CONTRIBUTING.md#creating-an-eclipse-development-environment

It's problematic that you don't provide a test case nor even a way for someone else to reproduce the problem. 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants