Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 346298

Summary: Error in the construction of a reference from DynamicEObject to DynamicEObject
Product: [Modeling] EMF Reporter: Miguel A. de Miguel <mmiguel>
Component: XML/XMIAssignee: Ed Merks <Ed.Merks>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Miguel A. de Miguel CLA 2011-05-18 12:34:56 EDT
Build Identifier: M20110210-1200

I'm working with uml models that include UML profile application and Stereotype application. XMI represent the stereotype application with DynamicEObject. In my examples the sterotypes includes associations from stereotypes to stereotypes.

When ecore.xmi is reading the file and is resolving the references makes call to EClassImpl::getFeatureID(EStructuralFeature feature). But the java reference that include as parameter is not the same as the references to EStructuralFeature (eAllStructuralFeaturesData) that includes EClassImpl. And EClassImple does not finds the corret feature ID and returns -1.ecore.xmi handles in a wrong way the feature (in my example it handles the feature as a container and it isn't a container).

I've modified EClassImpl to solve the problem (but I lnow that this is not the correct solution. I've included following modifications in line 1453 of EClassImpl:
        if (eAllStructuralFeaturesData[index] == feature || 
           (eAllStructuralFeaturesData[index].getFeatureID() == feature.getFeatureID() && 
        	eAllStructuralFeaturesData[index].getName().equals(feature.getName()) && 
        	eAllStructuralFeaturesData[index].eClass().getClassifierID() == feature.eClass().getClassifierID()))


This would not be correct for two features of two different EClass in two different EPackages with the same classifier id, and the same feature id.

I suppose that the source of the problem is that ecore.xmi does not locates the feature, and it creates a new instance. featureID in EClassImpl compare references and it does not compares values.

Reproducible: Always

Steps to Reproduce:
1. The models that I use includes profiles and to reproduce this profiles plugin are needed.
2. In the profiles the stereotypes include associations.
3. The stereotype applications must include references.
4. When ecore.xmi reads the file, it resolves the references in a worng way.
Comment 1 Ed Merks CLA 2011-05-18 13:15:14 EDT
Sorry, but I have no idea what problem you're having but the change to EClassImpl isn't appropriate; the getFeatureID method is supposed to return a valid ID only for actual features of the class, not for ones from any other class...

It sounds to me like your serialization is invalid in some way, but given you've shared no specific details (test cases) I can't comment on that. Perhaps you have more than one instance of the "same" Ecore model and are expecting them to behave like a single instance.  That's not supported.  You need to ensure that a single instance is consistently used.