Problems with OCL validation and derived properties [message #1827281] |
Tue, 12 May 2020 04:55  |
Eclipse User |
|
|
|
After my instances have been nicely passing all OCL validation, I have now added a derived attribute "isInitial" to my ecore model using the following oclinecore:
<eStructuralFeatures xsi:type="ecore:EAttribute" name="isInitial"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" volatile="true"
derived="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot">
<details key="derivation" value="machine.initial = self"/>
</eAnnotations>
</eStructuralFeatures>
The full meta-model is available here: https://bitbucket.org/dsldesign/dsldesign/src/derived_attr/mdsebook.fsm/model/fsm.ecore (in a temporary branch). The derived property is not used in any invariants. It is just hanging there.
The code generation seems to work, the generated code compiles, and I checked it contains some code for the new property. Unfortunately the validation without OCL seems to be failing on the very same instances on which it was not failing before the derived property has been added to the meta-model. This kinda contradicts my understanding of derived properties, but the problem is hopefully not fundamental, but related to some technicalities.
I narrowed down the problem to this exception activated during OCL validation:
java.lang.NullPointerException:
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleData.dynamicIsSet(EStructuralFeatureImpl.java:2293)
at mdsebook.fsm.impl.StateImpl.eIsSet(StateImpl.java:302)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1280)
at org.eclipse.emf.ecore.util.EObjectValidator.validate_DataValueConforms(EObjectValidator.java:832)
at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDataValueConforms(EObjectValidator.java:820)
at mdsebook.fsm.util.FsmValidator.validateState(FsmValidator.java:343)
at mdsebook.fsm.util.FsmValidator.validate(FsmValidator.java:103)
at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:324)
at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:257)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:244)
The exception disappears when I remove the derived property. I am truly puzzled. It might be caused by the derived property failing to compute on the instances (I will check), but why would this matter, if it is not even called? Any suggestions how to deal with it?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Problems with OCL validation and derived properties [message #1827518 is a reply to message #1827430] |
Sat, 16 May 2020 14:42  |
Eclipse User |
|
|
|
hi
Quote:However it is just possible (1%) that an orphan State might arise during some transformation and possibly be persisted at the root of a model.
Interesting example. I'm inclined to recommend a 0 lowerbound when that is remotely possible and an "InitialStateRequired" constraint to impose the semantics.
Regards
Ed Willink
[Updated on: Mon, 18 May 2020 03:16] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.09143 seconds