Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » eIsSet and multiple inheritance
eIsSet and multiple inheritance [message #501488] Wed, 02 December 2009 14:40 Go to next message
Sorin Fagateanu is currently offline Sorin FagateanuFriend
Messages: 46
Registered: July 2009
Member
Hi,

I have a multiple inheritance with a class A extending Element, and a class B extending A and PackageElement.

After code generation, in BImpl, all the attributes are created correctly, but eIsSet, eUnset, eSet, eGet does not delegate to PackageElementImpl for the features from PackageElement.

Example: visibilty. The setter/getter are correctly created (getVisibility(), setVisibility), but there is no reference to it from eIsSet/eUnset/eGet/eSet and there are problems when you try to acces the information directly as element.eGet(...VISIBILITY).

Is this a known problem, or did I forget something ?

Thank you in advance,

Sorin.

[Updated on: Wed, 02 December 2009 14:54]

Report message to a moderator

Re: eIsSet and multiple inheritance [message #501498 is a reply to message #501488] Wed, 02 December 2009 14:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Sorin,

Comments below.

Sorin Fagateanu wrote:
> Hi,
>
> I have a multiple inheritance with a class A extending Element, and a
> class B extending A and PackageElement.
>
> After code generation, in BImpl, all the attributes are created
> correctly, but eIsSet, eUnset, eSet, eGet does not delegate to
> PackageElementImpl for the features from PackageElement.
>
> Is this a known problem, or did I forget something ?
Java only support single class inheritance so it's not possible for
BImpl to extend both AImpl and PackageElementImpl. BImpl just
re-implement PackageElement from scratch.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: eIsSet and multiple inheritance [message #501506 is a reply to message #501498] Wed, 02 December 2009 15:30 Go to previous messageGo to next message
Sorin Fagateanu is currently offline Sorin FagateanuFriend
Messages: 46
Registered: July 2009
Member
Hi,

I am sorry i didn't give more details (I edited the original question so it may become clearer).

It is true that the methods from PackageElement are reimplemented in BImpl (ex: getVisibility(), setVisibility()), but the eIsGet/eUnset/eSet/eGet which are also generated, do not contain any reference to this methods, and when we try to access this information directly (as in
element.eGet(UMLPackage.eINSTANCE.getNamedElement_Visibility().getFeatureID())
), we get an error.

Thank you in advance,

Sorin.
Re: eIsSet and multiple inheritance [message #501525 is a reply to message #501506] Wed, 02 December 2009 16:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080306040500060505070604
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Sorin,

That sounds bad but I have my doubts given how extensively UML itself
uses multiple inheritance...

Sorin Fagateanu wrote:
> Hi,
>
> I am sorry i didn't give more details (I edited the original question
> so it may become clearer).
>
> It is true that the methods from PackageElement are reimplemented in
> BImpl (ex: getVisibility(), setVisibility()), but the
> eIsGet/eUnset/eSet/eGet which are also generated, do not contain any
> reference to this methods, and when we try to access this information
> directly (as in
> element.eGet(UMLPackage.eINSTANCE.getNamedElement_Visibility ().getFeatureID())
> ), we get an error.
This isn't a valid approach and I would expect it to fail in general.
You have to be *very careful* when using feature IDs because the correct
one is relative to the actual class and is computed by this method on
EClass.

/**
* <!-- begin-user-doc -->
* Returns the ID of the feature relative to this class, or -1 if
the feature is not in this class.
* @return the ID of the feature relative to this class, or -1 if
the feature is not in this class.
* <!-- end-user-doc -->
* @model
* @generated
*/
int getFeatureID(EStructuralFeature feature);

I'd expect you to use
element.eGet(UMLPackage.eINSTANCE.getNamedElement_Visibility ()) and for
that to work...
> Thank you in advance,
>
> Sorin.

--------------080306040500060505070604
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Sorin,<br>
<br>
That sounds bad but I have my doubts given how extensively UML itself
uses multiple inheritance...<br>
<br>
Sorin Fagateanu wrote:
<blockquote cite="mid:hf616h$36h$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
I am sorry i didn't  give more details (I edited the original question
so it may become clearer).
<br>
<br>
It is true that the methods from PackageElement are reimplemented in
BImpl (ex: getVisibility(), setVisibility()), but the
eIsGet/eUnset/eSet/eGet which are also generated, do not contain any
reference to this methods, and when we try to access this information
directly (as in
element.eGet(UMLPackage.eINSTANCE.getNamedElement_Visibility ().getFeatureID())
), we get an error.
<br>
</blockquote>
This isn't a valid approach and I would expect it to fail in general.
You have to be <b>very careful</b> when using feature IDs because the
correct one is relative to the actual class and is computed by this
method on EClass.<br>
<blockquote><small>  /**</small><br>
<small>   * &lt;!-- begin-user-doc --&gt;</small><br>
<small>   * Returns the ID of the feature relative to this class, or
-1 if the feature is not in this class.</small><br>
<small>   * @return the ID of the feature relative to this class, or
-1 if the feature is not in this class.</small><br>
<small>   * &lt;!-- end-user-doc --&gt;</small><br>
<small>   * @model</small><br>
<small>   * @generated</small><br>
<small>   */</small><br>
<small>  int getFeatureID(EStructuralFeature feature);</small><br>
</blockquote>
I'd expect you to use
element.eGet(UMLPackage.eINSTANCE.getNamedElement_Visibility ()) and for
that to work...<br>
<blockquote cite="mid:hf616h$36h$1@build.eclipse.org" type="cite">Thank
you in advance,
<br>
<br>
Sorin.
<br>
</blockquote>
</body>
</html>

--------------080306040500060505070604--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: eIsSet and multiple inheritance [message #502425 is a reply to message #501525] Tue, 08 December 2009 07:55 Go to previous messageGo to next message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
Dear Ed,

I am facing a similar problem regarding the use of multiple inheritance (on a metamodel that extends the UML2 metamodel).

I have a class Base that extends Element.
I have a class PackageableBase that extends Base and PackageableElement (in this order).

The generated PackageableBaseImpl extends BaseImpl. Because of the multiple inheritance, EMF generates inside my PackageableBaseImpl class:

* fields (and getters + setters) that are specific to PackageableElement: name, visibility, clientDependencies, etc. Until now everything is OK.
* eBaseStructuralFeatureID() that converts featureIDs from superclasses to featureIDs

Until now, everything is OK.

The only problem comes from the VISIBILITY field. In fact, the eGet, eSet ... family doesn't contain a proper CASE in its SWITCH (it does from all the other fields such as NAME, CLIENT_DEPENDENCY, etc). Because of this, when one of this methods is invoked with the VISIBILITY field (during COPY, or SAVE), the call is not properly managed, ending up with a NullPointerException.

I see in uml.ecore that PackageableElement has a "duplicates" annotation containing the "visibility" field, and perhaps this is related to my problem.

Perhaps there is an option during the UML-EMF conversion, or something else that could be specified to enforce the "correct" generation (as I wouldn't like to suppress the generated tag and modify the above methods (eSet, eIsSet, etc)).

Thank you in advance,
Cristi.
Re: eIsSet and multiple inheritance [message #502431 is a reply to message #502425] Tue, 08 December 2009 08:15 Go to previous messageGo to next message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
I see that if my Base class extends from NamedElement instead of Element, I have no more problems.

But I cannot understand exactly why. Is it because the "visibility" field declared in PackageableElement "redefines" the "visibility" field declared in NamedElement, so when a class extends PackageableElement it should extend NamedElement as well?

Best regards,
Cristi.

[Updated on: Tue, 08 December 2009 08:16]

Report message to a moderator

Re: eIsSet and multiple inheritance [message #502487 is a reply to message #502431] Tue, 08 December 2009 14:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Cristian,

UML is generated with an extended GenModel that has different behavior
than EMF base GenModel. Things like refinement are supported only in
UML's extended GenModel so best to ask about it on the UML newsgroup.
Probably if you extend UML you'd need to use their extended GenModel too.


Cristian wrote:
> I see that if my Base class extends from NamedElement instead of
> Element, I have no more problems.
> But I cannot understand exactly why. Is it because the "visibility"
> field declared in PackageableElement "redefines" the "visibility"
> field declared in NamedElement, so when a class extends
> PackageableElement it should extend as well NamedElement?
>
> Best regards,
> Cristi.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: eIsSet and multiple inheritance [message #502492 is a reply to message #502487] Tue, 08 December 2009 14:26 Go to previous message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
Thanks for the tip.

I have put the question in the UML2 forum:

http://www.eclipse.org/forums/index.php?t=msg&th=159092& amp;start=0&S=dfd67368d78811939c1443cb3f41f641
Previous Topic:dynamic_package loading metamodels
Next Topic:Ecore and ecore_diagram
Goto Forum:
  


Current Time: Wed Apr 24 15:50:00 GMT 2024

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

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

Back to the top