| Summary: | ArrayIndexOutOfBoundsException using Dynamic EMF | ||
|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Flavio Donze <flavio.donze> |
| Component: | Teneo | Assignee: | Martin Taal <mtaal> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Flavio Donze
As additional information, updated to version 1.1.2.v201009161849. Still same exception. I imported the sources and changed the following:
/** Sets an elist using the passed feature */
public static void setManyEFeatureValue(EStructuralFeature eFeature, Object value, BasicEObjectImpl owner) {
owner.eSet(eFeature, value);
// final DynamicValueHolder dvh = getValueHolder(owner);
// dvh.dynamicSet(getFeatureId(owner, eFeature), value);
}
/** Gets an elist using the passed feature */
public static EList<?> getManyEFeatureValue(EStructuralFeature eFeature, BasicEObjectImpl owner) {
// final DynamicValueHolder dvh = getValueHolder(owner);
// return (EList<?>) dvh.dynamicGet(getFeatureId(owner, eFeature));
return (EList<?>) owner.eGet(eFeature);
}
This got rid of the Exception and seems to work fine so far, but as stated earlier I don't know what getValueHolder(owner) is all about.
Hi Flavio,
I tried to reproduce this by having the same type of inheritance as you defined (so static extended by a dynamic and then again extended by a dynamic). With me it does not fail, this can happen because accidentally the feature ids are correctly computed.
What do you mean with this:
>>> I found that EcoreAccess.getManyEFeatureValue() uses the wrong feature id.
>>> EcoreAccess.getFeatureId() returns the actuall feature id but calls dynamicGet().
can you debug how the feature id is computed in this case? I think that's where the key of the issue can be found.
gr. Martin
Hi Martin As I see it the problem is that EcoreAccess.getFeatureId() returns the feature id/index calculated with the static and dynamic features together. For example DocumentNls.parts = 6. DynamicValueHolder in my case is then BasicEObjectImpl.EPropertiesHolderImpl, dynamicGet() and dynamicSet() expects then the dynamic feature id which would be 3. The parameter of the get and set method is called dynamicFeatureID and commented as: @param dynamicFeatureID the feature's index in the cached dynamic values. BasicEObjectImpl.EPropertiesHolderImpl holds an array eSettings[], it's size is 4 and on position 3 is the actual content of DocumentNls.parts. To get the value eSettings[dynamicFeatureID] is done, which then throws the exception with dynamicFeatureID being 6. You can't reproduce this? It only happens when having EFeatures in the dynamic object. DocumentNls.parts is a non containment 0..n Reference. Some additional information. BasicEObjectImpl.eGet(int featureID, boolean resolve, boolean coreType) does the following: int dynamicFeatureID = featureID - eStaticFeatureCount(); so the dynamicFeatureID is the id subtracted with the static feature count. In my case featureID=6 eStaticFeatureCount()=3 results in dynamicFeatureID=3 My mistake, I could reproduce it now, I have committed a fix and doing a build right away. gr. Martin A new build is available, can you try it and let me know if it solved? Thanks! gr. Martin Hi Martin WORKS! Thanks a lot for fixing! Good to hear! gr. Martin |