Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » EcoreUtil.delete giving UnsupportedOperationException
EcoreUtil.delete giving UnsupportedOperationException [message #1815523] Fri, 04 October 2019 05:48 Go to next message
Prajna VGFriend
Messages: 54
Registered: July 2018
Member
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 05:51]

Report message to a moderator

Re: EcoreUtil.delete giving UnsupportedOperationException [message #1815526 is a reply to message #1815523] Fri, 04 October 2019 08:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 09:19 Go to previous messageGo to next message
Prajna VGFriend
Messages: 54
Registered: July 2018
Member
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 09:20]

Report message to a moderator

Re: EcoreUtil.delete giving UnsupportedOperationException [message #1815565 is a reply to message #1815529] Sat, 05 October 2019 07:28 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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: Fri Apr 19 22:55:39 GMT 2024

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

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

Back to the top