Skip to main content



      Home
Home » Modeling » ATL » Containers deletion in Refinement mode
Containers deletion in Refinement mode [message #1870995] Thu, 12 September 2024 10:14 Go to next message
Eclipse UserFriend
I try to delete some packages (together with their content) from an UML model using an in-place transformation.

The point is that I got error messages that seem be raised by the deletion of their content. Basically I use a helper named "isInScope()" that returns a boolean: true if the element shall be kept, false if it shall be removed.

Not that any element that is not a root package inherits its "scope assessment" from its container, while there is a list of root packages that I want to keep in order to know what to do with them.

The deletion rule is the following:
rule removes {
	from src: UML!Element (not src.isInScope())
}


Here is the kind of error I get:

org.eclipse.m2m.atl.emftvm.util.VMException: Error deleting Administration:UML!Package.ownedComment from 464fb35e:UML!Comment: Cannot invoke "org.eclipse.emf.ecore.resource.Resource.getContents()" because the return value of "org.eclipse.emf.ecore.EObject.eResource()" is null

The package named "Administration" referenced by this message shall actually be deleted together with its content. The text of this message is not that clear and I would tend to read this sentence in the other way (i.e. the comment cannot be removed for ownedComment) but maybe I missed the point...

How should I proceed to make it work?
Re: Containers deletion in Refinement mode [message #1871004 is a reply to message #1870995] Thu, 12 September 2024 12:57 Go to previous messageGo to next message
Eclipse UserFriend
This is caused by an underlying EMF or UML exception. It appears EMF or UML does not like the order in which elements are deleted. Can you launch Eclipse from the command line and provide the Java stack trace that goes with this error?
Re: Containers deletion in Refinement mode [message #1871052 is a reply to message #1871004] Fri, 13 September 2024 03:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dennis,

Here what I got from executing it as an ANT task from within Eclipse. Is it sufficient?
  [emftvm.run] org.eclipse.m2m.atl.emftvm.util.VMException: Error deleting Administration:UML!Package.ownedComment from 34cfc7aa:UML!Comment: Cannot invoke "org.eclipse.emf.ecore.resource.Resource.getContents()" because the return value of "org.eclipse.emf.ecore.EObject.eResource()" is null
  [emftvm.run] at rule removes@applier#1(/StandardProfileConvertor_Gen/StandardProfile_Convertor.atl#[61:7-61:23])
  [emftvm.run] 	Local variables: [__trace__: TRACE!TraceLink = 48a2104e:TRACE!TraceLink, src: UML!Element = 34cfc7aa:UML!Comment]
  [emftvm.run] at static EMFTVM!ExecEnv::main() : Object(/StandardProfileConvertor_Gen/StandardProfile_Convertor.atl)
  [emftvm.run] 	Local variables: []
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl$DeletionEntry.process(ExecEnvImpl.java:227)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.deleteQueue(ExecEnvImpl.java:2383)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2239)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2075)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.runForOutputModelSet(RunTask.java:357)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.runForInOutModelSet(RunTask.java:320)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.runForInputModelSet(RunTask.java:298)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.innerExecute(RunTask.java:276)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.EMFTVMTask.execute(EMFTVMTask.java:98)
  [emftvm.run] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
  [emftvm.run] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  [emftvm.run] 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
  [emftvm.run] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
  [emftvm.run] 	at org.apache.tools.ant.Task.perform(Task.java:350)
  [emftvm.run] 	at org.apache.tools.ant.Target.execute(Target.java:449)
  [emftvm.run] 	at org.apache.tools.ant.Target.performTasks(Target.java:470)
  [emftvm.run] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
  [emftvm.run] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
  [emftvm.run] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
  [emftvm.run] 	at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:34)
  [emftvm.run] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
  [emftvm.run] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:714)
  [emftvm.run] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:530)
  [emftvm.run] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  [emftvm.run] 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
  [emftvm.run] 	at org.eclipse.ant.core.AntRunner.run(AntRunner.java:369)
  [emftvm.run] 	at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.lambda$0(AntLaunchDelegate.java:279)
  [emftvm.run] 	at java.base/java.lang.Thread.run(Thread.java:1583)
  [emftvm.run] Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.emf.ecore.resource.Resource.getContents()" because the return value of "org.eclipse.emf.ecore.EObject.eResource()" is null
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.updateResource(EMFTVMUtil.java:1053)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.removeRefValue(EMFTVMUtil.java:1036)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.removeMany(EMFTVMUtil.java:906)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.remove(EMFTVMUtil.java:696)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl$DeletionEntry.process(ExecEnvImpl.java:221)
  [emftvm.run] 	... 27 more


If you need the full trace will need your help for executing it from the command line because my tries were unsuccessful so far! :-)

[Updated on: Mon, 16 September 2024 02:19] by Moderator

Re: Containers deletion in Refinement mode [message #1871076 is a reply to message #1871052] Fri, 13 September 2024 11:05 Go to previous messageGo to next message
Eclipse UserFriend
That is sufficient, thank you!
Re: Containers deletion in Refinement mode [message #1871118 is a reply to message #1871076] Mon, 16 September 2024 08:36 Go to previous messageGo to next message
Eclipse UserFriend
Bug reproduced and logged: https://github.com/eclipse-atl/atl/issues/20
Re: Containers deletion in Refinement mode [message #1871130 is a reply to message #1871118] Mon, 16 September 2024 14:17 Go to previous messageGo to next message
Eclipse UserFriend
Fix can be installed from https://download.eclipse.org/mmt/atl/builds/nightly/ (ATL nightly builds update site)
Re: Containers deletion in Refinement mode [message #1871151 is a reply to message #1871130] Tue, 17 September 2024 03:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dennis,
Thank you but it looks like the fix doe snot completely resolve the issue. Indeed, another similar one now appears:
org.eclipse.m2m.atl.emftvm.util.VMException: Error deleting extension_unnamed1:UML!ExtensionEnd.lowerValue from :UML!LiteralInteger: Cannot invoke "org.eclipse.emf.ecore.resource.Resource.getContents()" because "vResource" is null
at rule removes@applier#1(platform:/resource//StandardProfileConvertor_Gen/StandardProfile_Convertor.atl#[61:7-61:23])
	Local variables: [__trace__: TRACE!TraceLink = c594021:TRACE!TraceLink, src: UML!Element = :UML!LiteralInteger]
at static EMFTVM!ExecEnv::main() : Object(platform:/resource//StandardProfileConvertor_Gen/StandardProfile_Convertor.atl)
	Local variables: []


Note: don't be mislead by the name of the transformation. At that time the only thing it does is removing elements that don't match a specific criteria:
rule removes {
	from src: UML!Element (not src.isInScope())
}

rule removesPkg extends removes {
	from src: UML!Package ((not src.isInScope()).debug(src.qualifiedName+' deleted'))
}


The purpose of the specialization for package is only to get a trace in the console

Here is the corresponding stack:
  [emftvm.run] org.eclipse.m2m.atl.emftvm.util.VMException: Error deleting extension_unnamed1:UML!ExtensionEnd.lowerValue from :UML!LiteralInteger: Cannot invoke "org.eclipse.emf.ecore.resource.Resource.getContents()" because "vResource" is null
  [emftvm.run] at rule removes@applier(/StandardProfileConvertor_Gen/StandardProfile_Convertor.atl)
  [emftvm.run] 	Local variables: [1860251c:TRACE!TraceLink, :UML!LiteralInteger]
  [emftvm.run] at static EMFTVM!ExecEnv::main() : Object(/StandardProfileConvertor_Gen/StandardProfile_Convertor.atl)
  [emftvm.run] 	Local variables: []
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl$DeletionEntry.process(ExecEnvImpl.java:227)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.deleteQueue(ExecEnvImpl.java:2387)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.matchAllSingle(ExecEnvImpl.java:2239)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.run(ExecEnvImpl.java:2075)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.runForOutputModelSet(RunTask.java:357)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.runForInOutModelSet(RunTask.java:320)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.runForInputModelSet(RunTask.java:298)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.RunTask.innerExecute(RunTask.java:276)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.ant.EMFTVMTask.execute(EMFTVMTask.java:98)
  [emftvm.run] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
  [emftvm.run] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  [emftvm.run] 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
  [emftvm.run] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
  [emftvm.run] 	at org.apache.tools.ant.Task.perform(Task.java:350)
  [emftvm.run] 	at org.apache.tools.ant.Target.execute(Target.java:449)
  [emftvm.run] 	at org.apache.tools.ant.Target.performTasks(Target.java:470)
  [emftvm.run] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
  [emftvm.run] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
  [emftvm.run] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
  [emftvm.run] 	at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:34)
  [emftvm.run] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
  [emftvm.run] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:714)
  [emftvm.run] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:530)
  [emftvm.run] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  [emftvm.run] 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
  [emftvm.run] 	at org.eclipse.ant.core.AntRunner.run(AntRunner.java:369)
  [emftvm.run] 	at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.lambda$0(AntLaunchDelegate.java:279)
  [emftvm.run] 	at java.base/java.lang.Thread.run(Thread.java:1583)
  [emftvm.run] Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.emf.ecore.resource.Resource.getContents()" because "vResource" is null
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.updateResource(EMFTVMUtil.java:1056)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.setSingle(EMFTVMUtil.java:744)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil.remove(EMFTVMUtil.java:709)
  [emftvm.run] 	at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl$DeletionEntry.process(ExecEnvImpl.java:221)
  [emftvm.run] 	... 27 more

Re: Containers deletion in Refinement mode [message #1871181 is a reply to message #1871151] Tue, 17 September 2024 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Sorry to hear that. I've reopened the bug, but I have not yet managed to reproduce the issue...
Re: Containers deletion in Refinement mode [message #1871361 is a reply to message #1871181] Mon, 23 September 2024 05:34 Go to previous messageGo to next message
Eclipse UserFriend
Dennis,

According to the console trace I can produce from the execution of the transformation based on that nightly built, it looks like all the classifiers are removed first, then all the properties, then all the packages. Is it intended? I would have expected removing the elements in the inverse order of their containment - whatever the nature of the element, since packages can have sub-packages, classes nested classifiers, etc...

Couldn't it have something to do with the issue?

[Updated on: Mon, 23 September 2024 05:38] by Moderator

Re: Containers deletion in Refinement mode [message #1871535 is a reply to message #1871361] Sat, 28 September 2024 18:12 Go to previous messageGo to next message
Eclipse UserFriend
I've managed to reproduce the issue, and have added another fix. Fix can be installed from https://download.eclipse.org/mmt/atl/builds/nightly/ (ATL nightly builds update site)
Re: Containers deletion in Refinement mode [message #1871538 is a reply to message #1871361] Sun, 29 September 2024 16:28 Go to previous messageGo to next message
Eclipse UserFriend
Yves BERNARD wrote on Mon, 23 September 2024 11:34
Dennis,

According to the console trace I can produce from the execution of the transformation based on that nightly built, it looks like all the classifiers are removed first, then all the properties, then all the packages. Is it intended? I would have expected removing the elements in the inverse order of their containment - whatever the nature of the element, since packages can have sub-packages, classes nested classifiers, etc...

Couldn't it have something to do with the issue?


The deletion process is a bit more complex than that. Model elements that are deleted by transformation rules are queued for deletion after all rules are executed. The deletion queue is then processed in two phases:

1. All incoming references to the to-be-deleted element are removed, for each to-be-deleted element.
2. All to-be-deleted elements are removed from their model (or Resource).

That means model elements are deleted in the order that you delete them in your transformation code, but deletion is delayed until rule execution has finished. This delay allows any code that tries to access deleted elements to still work, while the deleted elements will be removed afterwards.
Re: Containers deletion in Refinement mode [message #1871553 is a reply to message #1871538] Mon, 30 September 2024 02:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dennis,
Thanks for the explanation. I'l try the fix asap.
Re: Containers deletion in Refinement mode [message #1871562 is a reply to message #1871553] Mon, 30 September 2024 03:40 Go to previous message
Eclipse UserFriend
Dennis,
I confirm the issue I reported has disappeared with this fix.

Thanks a lot!
Previous Topic:Issue with cached Helpers
Next Topic:Accessing inherited tag values from applied stereotypes
Goto Forum:
  


Current Time: Tue Sep 23 05:07:02 EDT 2025

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

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

Back to the top