Skip to main content



      Home
Home » Eclipse Projects » Sirius » EcoreUtil.delete giving UnsupportedOperationException
EcoreUtil.delete giving UnsupportedOperationException [message #1815523] Fri, 04 October 2019 01:48 Go to next message
Eclipse UserFriend
Hi all,

I am getting following exception while deleting an object using

EcoreUtil.delete(eObject, true);

java.lang.UnsupportedOperationException 
	at org.eclipse.emf.common.util.BasicEList$UnmodifiableEList.remove(BasicEList.java:948)
	at org.eclipse.emf.ecore.util.EcoreUtil.remove(EcoreUtil.java:3220)
	at org.eclipse.emf.ecore.util.EcoreUtil.delete(EcoreUtil.java:3449)

Anyone knows the cause/solution for this exception? Any other way is there to delete an EObject programmatically?

[Updated on: Fri, 04 October 2019 01:51] by Moderator

Re: EcoreUtil.delete giving UnsupportedOperationException [message #1815526 is a reply to message #1815523] Fri, 04 October 2019 04:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi

You need to study the derived EObject whose EClass is not given.

Possibly the derived EClass is programmed defectively and should not be using an UnmodifiableEList.

More likely the instance of the derived EClass is part of a set of instances that should not be deleted and so your application algorithms are defective.

Your line numbers are a bit off wrt to the current EcoreUtil, but it looks like your problem occurs in

          if (!eObjects.contains(setting.getEObject()) && setting.getEStructuralFeature().isChangeable())
          {
            remove(setting, deletedEObject);
          }


so it would appear that the algorithmic bug could be in declaring a list feature to be changeable whiel implementing it with an UnmodifiableEList.

Perhaps you just need to mark it readonly in your model.

Regards

Ed Willink
Re: EcoreUtil.delete giving UnsupportedOperationException [message #1815529 is a reply to message #1815526] Fri, 04 October 2019 05:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed Willink,

Thanks for replying.

Yes exactly in that code you mentioned, I am getting that exception. But if I use EcoreUtil.remove(eObject); the exception will not occur.
But I am not sure I can use remove method instead of delete. Because delete method has parameter - recursive whether references to contained children should also be removed. I am not able to understand the exact difference between delete and remove!!

Regards,

Prajna

[Updated on: Fri, 04 October 2019 05:20] by Moderator

Re: EcoreUtil.delete giving UnsupportedOperationException [message #1815565 is a reply to message #1815529] Sat, 05 October 2019 03:28 Go to previous message
Eclipse UserFriend
Hi

Have you read the Javadoc? It seems pretty clear to me.

remove is a local elimination. i.e. the container relationship is trashed but nothing else. The removed object can be re-contained somewhere else.

delete is a global elimination. i.e. all relationships are trashed. The removed object is totally isolated, and should probably be left to be garbage collected, although you could reinitialize it.

Regards

Ed Willink
Previous Topic:Refresh diagram
Next Topic:Sirius validation issues with newValue / selection input
Goto Forum:
  


Current Time: Thu Jul 03 14:58:45 EDT 2025

Powered by FUDForum. Page generated in 0.23877 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top