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?