Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generated eBaseStructuralFeatureID issue
Generated eBaseStructuralFeatureID issue [message #1140514] Wed, 16 October 2013 12:06 Go to next message
Michal Kleczek is currently offline Michal KleczekFriend
Messages: 31
Registered: May 2013
Member
Hi,

I have the following ECore model (simplified)
abstract class Package<T extends PackageElement>
  reference elements : T (containment, inverse to PackageElement.package)

abstract class PackageElement
  reference package : Package (container, inverse to Package.elements)

class DomainElementPackage extends Package<DomainElement>

class DomainElement extends PackageElement

class Entity extends DomainElement


The generated code in EntityImpl.eBaseStructuralFeatureID:
	public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
		if (baseClass == PackageElement.class) {
			switch (derivedFeatureID) {
				case DomainPackage.ENTITY__PACKAGE: return DomainPackage.PACKAGE_ELEMENT__PACKAGE;
				default: return -1;
			}
		}
		if (baseClass == DomainElement.class) {
			switch (derivedFeatureID) {
				default: return -1;
			}
		}
		return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
	}


Which causes incorrect results from ECoreEList.contains() in case the number of Entity objects in a DomainElementPackage is greater than 4.

Is it a bug or there is something wrong with my metamodel?

Thanks,
Michal
Re: Generated eBaseStructuralFeatureID issue [message #1140596 is a reply to message #1140514] Wed, 16 October 2013 13:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Michael,

Just looking at your snippets doesn't really tell me what if anything is
going wrong. If you want me to have a look, please provide a
reproducible self contained test case as a zipped project attached to a
bugzilla. Please also indicate which version of EMF you're using; it
sounds vaguely like something the e4 team notices and was fixed...


On 16/10/2013 2:06 PM, Michal Kleczek wrote:
> Hi,
>
> I have the following ECore model (simplified)
>
> abstract class Package<T extends PackageElement>
> reference elements : T (containment, inverse to PackageElement.package)
>
> abstract class PackageElement
> reference package : Package (container, inverse to Package.elements)
>
> class DomainElementPackage extends Package<DomainElement>
>
> class DomainElement extends PackageElement
>
> class Entity extends DomainElement
>
>
> The generated code in EntityImpl.eBaseStructuralFeatureID:
>
> public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?>
> baseClass) {
> if (baseClass == PackageElement.class) {
> switch (derivedFeatureID) {
> case DomainPackage.ENTITY__PACKAGE: return
> DomainPackage.PACKAGE_ELEMENT__PACKAGE;
> default: return -1;
> }
> }
> if (baseClass == DomainElement.class) {
> switch (derivedFeatureID) {
> default: return -1;
> }
> }
> return super.eBaseStructuralFeatureID(derivedFeatureID,
> baseClass);
> }
>
>
> Which causes incorrect results from ECoreEList.contains() in case the
> number of Entity objects in a DomainElementPackage is greater than 4.
>
> Is it a bug or there is something wrong with my metamodel?
>
> Thanks,
> Michal


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generated eBaseStructuralFeatureID issue [message #1140620 is a reply to message #1140596] Wed, 16 October 2013 13:38 Go to previous messageGo to next message
Michal Kleczek is currently offline Michal KleczekFriend
Messages: 31
Registered: May 2013
Member
Preparing a test case is going to take me a while Smile
So in the meantime let me briefly explain the issue (look at the class hierarchy described in the first post):

Generated EntityImpl.eBaseStructuralFeatureID returns -1 in case baseClass == DomainElement.class
It should return DomainPackage.PACKAGE_ELEMENT__PACKAGE since Entity extends DomainElement which in turn extends PackageElement.

Thanks,
Michal
Re: Generated eBaseStructuralFeatureID issue [message #1140697 is a reply to message #1140620] Wed, 16 October 2013 14:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Michal,

I generally expect this kind of code only when there's multiple
inheritance involved, but you don't show that in your model example, so
it's pretty much impossible for me to comment, other than to ask again
which EMF version you're using.


On 16/10/2013 3:38 PM, Michal Kleczek wrote:
> Preparing a test case is going to take me a while :)
> So in the meantime let me briefly explain the issue (look at the class
> hierarchy described in the first post):
>
> Generated EntityImpl.eBaseStructuralFeatureID returns -1 in case
> baseClass == DomainElement.class
> It should return DomainPackage.PACKAGE_ELEMENT__PACKAGE since Entity
> extends DomainElement which in turn extends PackageElement.
>
> Thanks,
> Michal


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generated eBaseStructuralFeatureID issue [message #1140876 is a reply to message #1140697] Wed, 16 October 2013 17:24 Go to previous message
Michal Kleczek is currently offline Michal KleczekFriend
Messages: 31
Registered: May 2013
Member
EMF version is 2.9.1

Indeed - there is multiple inheritance involved - didn't show that in my snipplet. Actually it is:
class NamedElement

abstract class Package<T extends PackageElement> extends NamedElement
  reference elements : T (containment, inverse to PackageElement.package)

abstract class PackageElement
  reference package : Package (container, inverse to Package.elements)

class DomainElementPackage extends Package<DomainElement>

class DomainElement extends PackageElement

class Entity extends NamedElement, DomainElement
Previous Topic:EMF disable to open old model versions
Next Topic:Specifying enum operations in xcore
Goto Forum:
  


Current Time: Fri Apr 26 00:57:13 GMT 2024

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

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

Back to the top