What happened ?
This was also unexpected , I did not expect the instantiation to work in the first place (that old dogma about ocl not producing side-effects), but this kind of puzzle me. Maybe it's a configuration issue? or I just called some undocumented feature? If so, any way around to instantiate objects with pure OCL?

initializing withOCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
and parsing ocl as a file.

MDT/OCL currently has no evaluation support for pre or postconditions,
so evaluation will have proceded and just ignored your post conditions.
I presume this is what you describe as 'working'. Eventually you try to
use the return value, which was not constructed so you got an Invalid Class.

OCL 2.2 does not support construction of arbitrary objects.

OMG Issue 13057 suggests introduction of type constructors. This might
happen for OCL 2.3 when I proptotype it and write up a resolution.

On 23/02/2010 19:48, Alexandre Torres wrote:
> Hi, I was testing the use of post clauses with my operation with
> MDT-OCL. I'm running against an EMF model created from an UML metamodel,
> exported as an ECORE and generated automatically by eclipse.
>
> I defined in my metamodel class an operation called retrieveOrderForm:
>
> context OrderWindow::retrieveOrderForm(o:small::domain::Order): OrderForm
> post: result.date = o.date post: result.customer = o.customer.name
> post: result.order = o
> This was inspired by the example in section 8.3.8 of OCL spec. The
> objective is instantiate an OrderForm object.
> And it parsed and the operation worked! That was unexpected :) Great
> work folks 8) cooool But I got a DynamicEObjectImpl with Invalid_Class
> as result.
> :roll: mailto:org.eclipse.emf.ecore.impl.DynamicEObjectImpl@105ef53
> (eClass: mailto:org.eclipse.emf.ecore.impl.EClassImpl@905eba (name:
> Invalid_Class) (instanceClassName: null) (abstract: false, interface:
> false))
>
> What happened ?
> This was also unexpected 8o , I did not expect the instantiation to work
> in the first place (that old dogma about ocl not producing
> side-effects), but this kind of puzzle me. Maybe it's a configuration
> issue? or I just called some undocumented feature? If so, any way around
> to instantiate objects with pure OCL?
>
> initializing with
> OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
> and parsing ocl as a file.
>
> thanks in advance.
>]]>Ed Willink2010-02-23T20:17:34-00:00Re: Operation, Instantiation and post clause: Invalid Class?https://www.eclipse.org/forums/index.php/mv/msg/163207/516400/#msg_516400
Parameter
The operation asProperty results in a property that has the same name, type, etc. as the parameter.
context Parameter::asProperty(): Property
pre: -- none
post: result.name = self.name
post: result.type = self.type
post: result.upperValue = 1
post: result.lowerValue = 1
post: result.isOrdered = true
post: result.isStatic = false
post: result.visibility = VisibilityKind::private

Looks like an instantiation to me

Anyway I expected something like an exception "This feature exists only in your dreams" so i got excited with an invalid_class...

Thanks for the ultra-fast answer. ]]>Alexandre Torres2010-02-23T20:31:02-00:00Re: Operation, Instantiation and post clause: Invalid Class?https://www.eclipse.org/forums/index.php/mv/msg/163207/516419/#msg_516419
Yes, for very simple classes the specification of behaviour can be
trivially interpreted as an instantiation. However consider