Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Latest EmfModelHandler CLONING referenced elements - possible bug?
[ATL] Latest EmfModelHandler CLONING referenced elements - possible bug? [message #66836] Wed, 28 November 2007 10:58 Go to next message
Lorenzo Dalla Vecchia is currently offline Lorenzo Dalla VecchiaFriend
Messages: 58
Registered: July 2009
Member
Hi.

While trying to run a transformation developed in the 2.0rc2 bundle
stand-alone, I discovered a possible bug.
To use ATL stand-alone, I had to export the latest
org.eclipse.m2m.atl.engine plugin from the CVS.

Since I'm using EMF, I first get a AtlEMFModelHandler using the following
code:

handler = AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);

Next, I load all relevant models and metamodels using AtlEMFModelHandler
"loadModel" method.
Then I run the transformation using the AtlLauncher class "launch" method.

All seemed to work fine, except for a few inconsistencies in the generated
target model.
After hours of painful debugging through ATL "debug" operation I found what
was causing the inconsistencies in the target model. Appearently, when the
source model was loaded, all elements referenced (but not contained) are
cloned/copied instead of being referenced.
I discovered this using hashCode() java method on the elements themselves
and of their references inside other elements, finding different hash codes,
indicating multiple instances. The same transformation with the same input
models when run in ATL 2.0rc2 bundle does not show the problem (every
element retains its hash code when referenced - only one instance exist).

This problem generates errors in my transformation since I'm using elements
(that means their hashes) as keys in a module level Map.

Now, is this copying/cloning the intended behaviour? Is it possible to work
around it, maybe loading the Ecore model in a different way?

Thanks.

--
Lorenzo
Re: [ATL] Latest EmfModelHandler CLONING referenced elements - possible bug? [message #67731 is a reply to message #66836] Thu, 29 November 2007 23:45 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

Could you please open a bugzilla entry for this issue?
It would also help if you could attach necessary files to reproduce the
behavior you observed.


Thanks,

Frédéric Jouault


Lorenzo Dalla Vecchia wrote:
> Hi.
>
> While trying to run a transformation developed in the 2.0rc2 bundle
> stand-alone, I discovered a possible bug.
> To use ATL stand-alone, I had to export the latest
> org.eclipse.m2m.atl.engine plugin from the CVS.
>
> Since I'm using EMF, I first get a AtlEMFModelHandler using the
> following code:
>
> handler = AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);
>
> Next, I load all relevant models and metamodels using AtlEMFModelHandler
> "loadModel" method.
> Then I run the transformation using the AtlLauncher class "launch" method.
>
> All seemed to work fine, except for a few inconsistencies in the
> generated target model.
> After hours of painful debugging through ATL "debug" operation I found
> what was causing the inconsistencies in the target model. Appearently,
> when the source model was loaded, all elements referenced (but not
> contained) are cloned/copied instead of being referenced.
> I discovered this using hashCode() java method on the elements
> themselves and of their references inside other elements, finding
> different hash codes, indicating multiple instances. The same
> transformation with the same input models when run in ATL 2.0rc2 bundle
> does not show the problem (every element retains its hash code when
> referenced - only one instance exist).
>
> This problem generates errors in my transformation since I'm using
> elements (that means their hashes) as keys in a module level Map.
>
> Now, is this copying/cloning the intended behaviour? Is it possible to
> work around it, maybe loading the Ecore model in a different way?
>
> Thanks.
>
> --
> Lorenzo
Re: [ATL] Latest EmfModelHandler CLONING referenced elements - possible bug? [message #67964 is a reply to message #67731] Sun, 02 December 2007 13:47 Go to previous messageGo to next message
Lorenzo Dalla Vecchia is currently offline Lorenzo Dalla VecchiaFriend
Messages: 58
Registered: July 2009
Member
>> While trying to run a transformation developed in the 2.0rc2 bundle
>> stand-alone, I discovered a possible bug. [...]
>> Appearently, when the source model was loaded, all elements referenced
>> (but not contained) are cloned/copied instead of being referenced.
>
> Could you please open a bugzilla entry for this issue?
> It would also help if you could attach necessary files to reproduce the
> behavior you observed.

While creating a test case to reproduce the bug, I discovered that
referenced objects are cloned only if in the ecore file they are referenced
using the filename itself, like this:

filename.ecore#//@elements.2

By removing the filename and leaving only the fragment, like

#//@elements.2

everything works fine and elements are not cloned.

My guess is that the engine I'm invoking stand-alone (compiled last week
from CVS) treats references with filenames as external, loading the same
Ecore file twice, even if the filename is the same. This causes a copy of
every model element to be generated in memory and cross-referenced into the
"main" model being loaded.
I had never encountered this problem before because the ATL engine included
in the current 2.0rc2 bundle seems not to care about this, treating
references with same filename as the file being loaded as no filename was
specified.

In case it matters, I'm generating the Ecore file using EMF API and this
creates filename-references automatically: if I save the model using the
bundled reflective editor, filenames are not included.

--
Lorenzo
Re: [ATL] Latest EmfModelHandler CLONING referenced elements - possible bug? [message #67985 is a reply to message #67964] Sun, 02 December 2007 17:49 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

How do you load the model?

I am asking, because if you load it by giving an InputStream to EMF,
then it has no way to know that these references are to the same file.
It is usually better to give EMF an EMF URI.

If this is not your problem, then we have to continue looking for the
actual cause.


Regards,

Frédéric Jouault


Lorenzo Dalla Vecchia wrote:
>>> While trying to run a transformation developed in the 2.0rc2 bundle
>>> stand-alone, I discovered a possible bug. [...]
>>> Appearently, when the source model was loaded, all elements referenced
>>> (but not contained) are cloned/copied instead of being referenced.
>>
>> Could you please open a bugzilla entry for this issue?
>> It would also help if you could attach necessary files to reproduce
>> the behavior you observed.
>
> While creating a test case to reproduce the bug, I discovered that
> referenced objects are cloned only if in the ecore file they are
> referenced using the filename itself, like this:
>
> filename.ecore#//@elements.2
>
> By removing the filename and leaving only the fragment, like
>
> #//@elements.2
>
> everything works fine and elements are not cloned.
>
> My guess is that the engine I'm invoking stand-alone (compiled last week
> from CVS) treats references with filenames as external, loading the same
> Ecore file twice, even if the filename is the same. This causes a copy
> of every model element to be generated in memory and cross-referenced
> into the "main" model being loaded.
> I had never encountered this problem before because the ATL engine
> included in the current 2.0rc2 bundle seems not to care about this,
> treating references with same filename as the file being loaded as no
> filename was specified.
>
> In case it matters, I'm generating the Ecore file using EMF API and this
> creates filename-references automatically: if I save the model using the
> bundled reflective editor, filenames are not included.
>
> --
> Lorenzo
>
Re: [ATL] Latest EmfModelHandler CLONING referenced elements - possible bug? [message #68029 is a reply to message #67985] Sun, 02 December 2007 21:42 Go to previous message
Lorenzo Dalla Vecchia is currently offline Lorenzo Dalla VecchiaFriend
Messages: 58
Registered: July 2009
Member
Hello.

> How do you load the model?

I'm using an InputStream. First thing I create a URL and then use its
openStream() method.

> I am asking, because if you load it by giving an InputStream to EMF, then
> it has no way to know that these references are to the same file.

Of course you are right! I completely forgot that I was using a stream to
load the file.

> It is usually better to give EMF an EMF URI.

I checked the base type AtlModelHandler I didn't suspect that the derived
AtlEMFModelHandler offered
more options for loading models.
After correcting the code to load with an URI, everything works perfectly.

Thanks for helping me solving this!

--
Lorenzo
Previous Topic:classes hidden in trasformation
Next Topic:[ATL] EJavaClass
Goto Forum:
  


Current Time: Sun Apr 11 23:10:46 GMT 2021

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

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

Back to the top