Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL does not like EList in operation parameters
icon9.gif  ATL does not like EList in operation parameters [message #1748495] Wed, 23 November 2016 15:36 Go to next message
Leonardo Montecchi is currently offline Leonardo MontecchiFriend
Messages: 7
Registered: September 2013
Junior Member
Hi all,

I am writing some transformations between metamodels that I defined using Ecore.
In one of those metamodels I defined some operations, using OCL. In particular I defined the following operation:

evaluate(assignments tmdl::core::Assignment[*]) : ecore::EInt

This translates into the following signature from the generated code:

int evaluate(EList<Assignment> assignments);

ATL correctly recognizes the existence of this operation, but it throws an exception every time I try to call it using a collection of 'Assignment' objects as a parameter, e.g.:

value <- tm.value.evaluate(TMDLEX!Assignment.allInstances()->asSequence())

throws:

org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: template!<unnamed>.evaluate(java.util.ArrayList)

It appears that ATL is not able to match EList objects against its collections types. I am aware of the genmodel option to "Suppress EMF Types", and in fact it works correctly if I select that option. However I am afraid of the impact of this option, which as I understand is not recommended.

Also, it seems more like a bug in ATL, because it is able to properly handle EList objects in other situations, for example as fields of model elements.

Do you have any suggestions?

Thanks,
Leonardo.


Leonardo Montecchi, PhD Student
Università degli Studi di Firenze
Re: ATL does not like EList in operation parameters [message #1748512 is a reply to message #1748495] Wed, 23 November 2016 20:08 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 365
Registered: September 2012
Location: Belgium
Senior Member

The EList collection type is fine as a method return type, but as input parameter type it is too restrictive. You should not use the specific EList type for input parameters, but rather the general List or Collection type.

EDIT: I've verified that the standard EMF code generator will always use EList for anything with a multiplicity higher than 1, including input parameters (see attached Eclipse project). This is indeed a mismatch, and we may fix this in the latest EMFTVM runtime.

There is a workaround in EMF: you can specify java.util.List as a new EDataType in your metamodel, and add an ETypeParameter "T" as child. You can then use that type for an input parameter, using the standard [0-1] multiplicity, and bind the ETypeParameter T to the Assignment EClass. This is what the 'otherOperation" in the attached Eclipse project does.


Cheers,
Dennis

[Updated on: Wed, 23 November 2016 20:32]

Report message to a moderator

Re: ATL does not like EList in operation parameters [message #1748515 is a reply to message #1748512] Wed, 23 November 2016 21:05 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 365
Registered: September 2012
Location: Belgium
Senior Member

...there! The latest ATL/EMFTVM build on Marketplace should support EList input parameters with ATL Sequence values. Can you try your transformation with EMFTVM?

Cheers,
Dennis
Re: ATL does not like EList in operation parameters [message #1748640 is a reply to message #1748515] Fri, 25 November 2016 15:18 Go to previous messageGo to next message
Leonardo Montecchi is currently offline Leonardo MontecchiFriend
Messages: 7
Registered: September 2013
Junior Member
Hi Dennis,
Thank you for your quick and accurate response!

I did not know about EMFTVM, I tried it and it seems to solve that problem about ELists. However, I am having several other issues, it seems that the compiler is more strict than the "normal" one, is it true?

I managed to solve most of them, but now I am struggling with the following problem.
I have a lazy abstract rule that looks like the following:

lazy abstract rule Marking {
	from
		tm : SANT!Marking
	to
		m : SAN!Marking
}

where SAN!Marking and SANT!Marking are both abstract classes, from different metamodels. This rule is then extended by several other lazy rules. This was working perfectly with the normal compiler, but now I get:

org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.IllegalArgumentException: The class 'Marking' is not a valid classifier

Any suggestions?

Thanks,
Leonardo.


Leonardo Montecchi, PhD Student
Università degli Studi di Firenze
Re: ATL does not like EList in operation parameters [message #1748648 is a reply to message #1748640] Fri, 25 November 2016 16:58 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 365
Registered: September 2012
Location: Belgium
Senior Member

Somehow, EMFTVM cannot find the EClassifier "Marking" at load-time. Unfortunately, we don't know which of the two meta-models to check. Can you verify the presence of the "Marking" meta class in both meta models?

Cheers,
Dennis
Re: ATL does not like EList in operation parameters [message #1748662 is a reply to message #1748648] Fri, 25 November 2016 21:53 Go to previous messageGo to next message
louis andia. is currently offline louis andia.Friend
Messages: 47
Registered: November 2016
Member
Are you sure about your rule?
Matching on an abstract class ok, but It's make no sense to create an abstract class. By definition, you can't create an abstract class, only a child of this class.
Re: ATL does not like EList in operation parameters [message #1748686 is a reply to message #1748662] Sat, 26 November 2016 20:13 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 365
Registered: September 2012
Location: Belgium
Senior Member

Specifying abstract classes in the output of an abstract rule is no problem.

Cheers,
Dennis
Previous Topic:ATL - two sources (with restrictions) in one rule
Next Topic:Simple Transformation Question
Goto Forum:
  


Current Time: Sat Jun 23 18:13:57 GMT 2018

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

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

Back to the top