Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Order of multi-inheritance is not deterministic?
Order of multi-inheritance is not deterministic? [message #1864843] Sun, 14 April 2024 13:16 Go to next message
Janek Schumann is currently offline Janek SchumannFriend
Messages: 1
Registered: April 2024
Junior Member
Dear community,

I am scratching my head about how EMF is determining the order of multi-inheritance.

I have an UML model, which looks like this:
[...]
class AElement {}

class ANamedElement extends AElement, uml::NamedElement {}
[...]


In XMI it looks like this:
[...]
    <packagedElement xmi:type="uml:Class" xmi:id="ee6ef34f-78d7-4083-b4e3-f2e78195a649" name="AElement" isAbstract="true">
         [...]
    </packagedElement>
    [...]
    <packagedElement xmi:type="uml:Class" xmi:id="_U4z8oO9DEe6MqtNwAzLkvA" name="ANamedElement" isAbstract="true">
        <generalization xmi:type="uml:Generalization" xmi:id="_N7AlEPpcEe6Gy5UW20a7qg" general="ee6ef34f-78d7-4083-b4e3-f2e78195a649"/>
        <generalization xmi:type="uml:Generalization" xmi:id="_PXDsUPpcEe6Gy5UW20a7qg">
          <general xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#NamedElement"/>
        </generalization>
         [...]
    </packagedElement>
[...]


I load the UML model into a genmodel, which generates an ecore looking like this:
[...]
abstract class ANamedElement extends uml::NamedElement, AElement
[...]


Generating code obviously follows the Ecore and not the UML definition. This leads to the constructor of ANamedElement to call the constructor of uml::NamedElement instead of AElement.
HOWEVER, the constructor of AElement sets some field, especially the elements ID. Since the inheritance is mixed up, this constructor is never called and the fields never set.


Why is EMF changing up the order of inheritance? It is not following the defined order as it should IMHO.

Fixing the Ecore everytime I reload the Genmodel from a modified UML model is not practical at all.
I could manually override the code in each constructor but that doesn't seem practical either.

Any ideas?
Re: Order of multi-inheritance is not deterministic? [message #1864848 is a reply to message #1864843] Mon, 15 April 2024 07:23 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
The mapping from UML2 Ecore is implemented by UML2.

https://www.eclipse.org/forums/index.php/f/117/


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] EmbeddedRepositoryExample is not working
Next Topic:UI Issue with using Modeling Nature
Goto Forum:
  


Current Time: Thu May 02 09:22:42 GMT 2024

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

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

Back to the top