Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsEvaluation of derived OCL Ecore attributes from Java
https://www.eclipse.org/forums/index.php/mv/msg/1094056/1791710/#msg_1791710
My use case matches very well what is described here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=420208 (which comes from a thread here: https://www.eclipse.org/forums/index.php/t/561711/).
It seems that this is not really a bug, but rather bad user initialization. However, I do not understand what to do to workaround the problem.
I made an effort to read about possible solutions. That's what I tried:
make sure that Operation Reflection is true
explicit Use Delegates = true as annotation
Used the following initialization to comply with this statement "SettingDelegateFactory registration must occur before the static initialization of the EMF generated classes" (from https://bugs.eclipse.org/bugs/show_bug.cgi?id=420208)
String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
new OCLSettingDelegateFactory.Global());
You can find here attached (i) a EMF project with a simple metamodel embedding OCL expressions to define derived attributes and (ii) a plugin that shows how I currently do model queries (from Java). The plugin also contains a model instance which conforms to the metamodel (in models/). What I get is, for example, that once I try to access
ca.getModel()
(line 42 in com.test.javaload.dummy.loader.DummyModelLoader) I always get a NPE.