[OCL] ClassCastException for constraint on static profile [message #1713412] |
Tue, 03 November 2015 21:20 |
Johan Van Noten Messages: 87 Registered: July 2009 |
Member |
|
|
Environment: Mars.1 + Papyrus Today's nightly
The reproduction scenario below leads to a failing OCL constraint (ClassCastException).
I have been trying to correct it, but don't find a solution.
The issue is not specific to this OCL constraint, but rather to the concept: "configuring a static profile + OCL".
So the core question is: "What are the correct GenModel options to make sure that OCL constraints on my static profile are correctly evaluated?"
Tried:
* Same profile, but on dynamically applied --> works
* Read OCLinEcore documentation, but didn't provide a clue wrt this problem
* Internet search, seems not to be a frequent issue.
* Tried on Luna, same issue.
Scenario:
I list the steps I tried to come to my static profile, each step corresponds to a directory in the attached archive.
In order to reuse, please remove the .v0 etc extension from the dirs.
v0 - Just the profile, no genmodel yet
v1 - Add GenModel, default settings (only add base package and point model code to /src-gen), generate Model code, add static profile definition to the plugin.xml
Code: MyClassImpl seems to have "if (false)" code.
Runtime: No validation happens
v2 - Reload GenModel, set Validation Delegates = Process.
Code: no change
Runtime: no change
v3 - Reload GenModel, set Invocation Delegates = Process.
Code: MyClassImpl now contains "return MyProfileValidator.validate(...". Seems real validation code.
Runtime: Model validation error...
An exception occurred while delegating evaluation of the 'Constraint1' invariant on 'MyClass':
java.lang.ClassCastException: org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global
cannot be cast to org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory
The attachment also contains a test-project com.ecme.sandbox which is to be imported in the runtime environment (as usual for static profiles).
Thanks,
Johan
|
|
|
|
|
|
|
Re: [OCL] ClassCastException for constraint on static profile [message #1716957 is a reply to message #1714295] |
Wed, 09 December 2015 10:00 |
|
Please note that there are two different ways to add validation constraints and both involve a plugin with generated code (therefore, it is quite easy to confuse these two - I will improve the Papyrus documentation with respect to this aspect).
(1) Use the standard tooling with validation delegate in ecore & generated code. This is currently not working with OCL and produces the class cast exception in bug 482143
(2) Ignore the validation delegate and use the Papyrus DSML generator to generate a plugin with the constraints embedded into the plugin.xml. This is what we currently use for Papyrus-RT. Eventually, Papyrus might drop the support for this mechanism once the first one is fully working, but there are no concrete decisions yet and it will certainly still be supported in the near future.
|
|
|
Powered by
FUDForum. Page generated in 0.03028 seconds