Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338157 - BasicFeatureMap#resolve(int, Entry) may cause ArrayStoreException
Summary: BasicFeatureMap#resolve(int, Entry) may cause ArrayStoreException
Status: RESOLVED WONTFIX
Alias: None
Product: EMF
Classification: Modeling
Component: Core (show other bugs)
Version: 2.7.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 16:34 EST by Alex Boyko CLA
Modified: 2011-02-24 17:14 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Boyko CLA 2011-02-24 16:34:59 EST
Here is the situation:
I have an Element with a feature map Any. I have containment feature MyFeature that belongs to an EClass Clazz, where Clazz and Element.eClass() are not related at all (i.e MyFeature is not inherited).
The feature map is being added an entry: Element.getAny().put(MyFeature, someEObject)

When the entries of the Any feature map are being resolved a problem originates between lines 2624-2628, while resolving the entry added above.

int inverseFeatureID = InternalEObject.EOPPOSITE_FEATURE_BASE - owner.eClass().getFeatureID(reference);
Statement above assigns 0 to inverseFeatureID. InternalEObject.EOPPOSITE_FEATURE_BASE == -1 and since owner == Element, the eClass of which doesn't define MyFeature, owner.eClass().getFeatureID(reference) == -1 too. Hence -1-(-1) == 0.

0 is considered to be a valid feature id, in my case it corresponds to EAnnotations, and hence someEObject is being added to array of EAnnotation and hence the ArrayStoreException.

Looks like for this to work properly the featureId must be -1.
Comment 1 Ed Merks CLA 2011-02-24 17:14:31 EST
I'll need a test case, not a verbal description.  Please reopen only if you can provide one.  It must be self contained without dependencies on non-EMF libraries.

Note also that if what you're trying to do isn't valid anyway (it doesn't sound like Any should allow MyFeature but who can say from your description) and fails in some way as a result, it's unlikely I'll do anything to make it fail differently, particularly if additional checks would potentially have significant runtime penalty for the common case.  It certainly doesn't sound like your model is one that would be produced from an XML Schema because they don't support cross document containment...