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

Bug 349915

Summary: ArrayIndexOutOfBoundsException working with Dynamic Features
Product: [Modeling] EMF Reporter: Andres Alvarez Mattos <aamattos>
Component: CoreAssignee: Ed Merks <Ed.Merks>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Andres Alvarez Mattos CLA 2011-06-21 05:32:58 EDT
Build Identifier: 20110301-1815

If working with Dynamic Features, the generaded accessors code call " Object eDynamicGet(int dynamicFeatureID, EStructuralFeature eFeature, boolean resolve, boolean coreType)" instead of "Object eDynamicGet(int featureID, boolean resolve, boolean coreType)" causing an ArrayIndexOutOfBoundsException when the eClass extends a Class with static features. 

Reproducible: Always

Steps to Reproduce:
1. Create in a model, a Class that extends ENamedElement (from ecore)
2. Create one or more EAttributes
2. Set de genmodel property "Feature Delegation" to "Dynamic"
3. Generate Code
Comment 1 Ed Merks CLA 2011-06-21 12:32:05 EDT
You can't use dynamic delegation when extending a statically generated base class.
Comment 2 Andres Alvarez Mattos CLA 2011-06-21 12:39:15 EDT
With Reflective Feature Delegation I don't have this problem. Can I asume that when extending a statically generated base
class I should work with "Reflective" mode ?
Comment 3 Ed Merks CLA 2011-06-21 12:53:12 EDT
Yes, I was going to mention that I wasn't even sure if reflective works.  But dynamic is definitely optimized to make assumptions that everything is fully dynamic.  I.e., look at the extra overhead of the other version of eDynamicGet.

  public Object eDynamicGet(int featureID, boolean resolve, boolean coreType)
  {
    return eDynamicGet(featureID - eStaticFeatureCount(), eClass().getEStructuralFeature(featureID), resolve, coreType);
  }


It has to do more work just to call a method that could be more efficiently called directly.

I'm not sure the value of using either dynamic or reflective when the base class is neither...