Binary compatibility of EMF models [message #1850731] |
Tue, 15 March 2022 12:56  |
Eclipse User |
|
|
|
Hi,
there is a so called core EMF model in our software.
In the package CorePackage there is an integer constant CORE...FEATURE_COUNT.
Another plugin is consuming the core plugin and extends this EMF model by extending EClasses.
If we add features in the CorePackage to existing EClasses the plugins become binary incompatible since integers are inlined.
Basically in the source code it says:
in CorePackage ... CORE...FEATURE_COUNT = 42.
in the using plugin:
UsingPackage ... SOME_FEATURE = CorePackage.CORE...FEATURE_COUNT + 1.
(which is 43)
After we add a new feature it says:
in CorePackage ... CORE...FEATURE_COUNT = 43.
in the using plugin still (of course):
UsingPackage ... SOME_FEATURE = CorePackage.CORE...FEATURE_COUNT + 1. (which is 44 now)
BUT in the class file it says something like this (don't nail me on the syntax :) )
Due to inlining:
CorePackage ... CORE...FEATURE_COUNT = 43
UsingPackage ... SOME_FEATURE = 43.
This leads to a stackoverflow error when loading and unloading a resource since eIsSet in an iteration for all features (feature ID are used).
Is there any other solution than re-compile the using plugin?
Anything to overcome this?
Thanks,
Marcus
|
|
|
|
|
Re: Binary compatibility of EMF models [message #1850752 is a reply to message #1850746] |
Wed, 16 March 2022 02:11   |
Eclipse User |
|
|
|
Ed,
This topic is not about extending Ecore, it is about extending some other model, which is of course common practice. There was no attempt to convince you of anything but rather an outline of how the feature constants are actually generated in the package interface and how these are actually used in the generated reflective methods. It's implemented like this so that EObjejct.eGet performs faster than HashMap.get but has the drawback that derived models need to be recompiled, exactly as Marcus has observed.
With the suggested property set, the generated implementation class has a generated constant like this:
private static final int EOFFSET_CORRECTION = XyzPackage.Literals.ABC.getFeatureID(XyzPackage.Literals.ABC__FEATURE) - XyzPackage.ABC__FEATURE; which dynamically evaluates the offset between the actual computed feature ID and the static constant feature ID. That value is then used in the generated methods to "correct" the static value, e.g., like this:
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID - EOFFSET_CORRECTION)
{ Please try to keep your followup observations focused on the topic rather than on tangential topics or potential diseases.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04004 seconds