Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » cast to EFloat?
cast to EFloat? [message #830912] Wed, 28 March 2012 07:55 Go to next message
Joel Greenyer is currently offline Joel GreenyerFriend
Messages: 170
Registered: July 2009
Senior Member
Hi,
in our model transformation tool, we use OCL to specify constraints and assignments.
Recently, we discovered a problem with EFloat attributes---it seems that writing e.g. "10.0" evaluates to a double value, which then leads to a ClassCastException during assignments.

java.lang.ClassCastException: The value of type 'class java.lang.Double' must be of type 'class java.lang.Float'

is there any way to specify in OCL that a value should be cast to float/EFloat or do we have to provide for that in our transformation engine?

Thanks

Joel
Re: cast to EFloat? [message #830985 is a reply to message #830912] Wed, 28 March 2012 09:56 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

In principle OCL only has Real, which should be and are represented by
implementations of the RealValue interface in the new pivot-based
Eclipse OCL.

The Ecore-based and UML-based versions of Eclipse OCL use Double and
sometimes Float directly, providing obscure opportunities for the kind
of problem you see. Some of these were fixed in the Indigo release,
others are too difficult to weed out and are one of the motivations for
the new pivot-based Eclipse with a predictable polymorphic Value hierarchy.

The main users of Eclipse OCL for transformation within Eclipse are
likely to move to the new Eclipse after Juno. You may want to consider
whether your transformation should do so too.

In the short term, you may find that the problem goes away in Indigo. If
not then try to avoid the Float hitting the OCL engine. If you can
provide a stack trace, it may be fixable for Juno.

Regards

Ed Willink

On 28/03/2012 03:55, Joel Greenyer wrote:
> Hi,
> in our model transformation tool, we use OCL to specify constraints
> and assignments.
> Recently, we discovered a problem with EFloat attributes---it seems
> that writing e.g. "10.0" evaluates to a double value, which then leads
> to a ClassCastException during assignments.
>
> java.lang.ClassCastException: The value of type 'class
> java.lang.Double' must be of type 'class java.lang.Float'
>
> is there any way to specify in OCL that a value should be cast to
> float/EFloat or do we have to provide for that in our transformation
> engine?
>
> Thanks
>
> Joel
Re: cast to EFloat? [message #831036 is a reply to message #830985] Wed, 28 March 2012 11:28 Go to previous message
Joel Greenyer is currently offline Joel GreenyerFriend
Messages: 170
Registered: July 2009
Senior Member
Hi Ed,
thanks for clarifying this.

Best

Joel

On 28.03.2012 11:56, Ed Willink wrote:
> Hi
>
> In principle OCL only has Real, which should be and are represented by implementations of the RealValue interface in the new pivot-based Eclipse OCL.
>
> The Ecore-based and UML-based versions of Eclipse OCL use Double and sometimes Float directly, providing obscure opportunities for the kind of problem you see. Some of these were fixed in the Indigo release, others are too difficult to weed out and are one of the motivations for the new pivot-based Eclipse with a predictable polymorphic Value hierarchy.
>
> The main users of Eclipse OCL for transformation within Eclipse are likely to move to the new Eclipse after Juno. You may want to consider whether your transformation should do so too.
>
> In the short term, you may find that the problem goes away in Indigo. If not then try to avoid the Float hitting the OCL engine. If you can provide a stack trace, it may be fixable for Juno.
>
> Regards
>
> Ed Willink
>
> On 28/03/2012 03:55, Joel Greenyer wrote:
>> Hi,
>> in our model transformation tool, we use OCL to specify constraints and assignments.
>> Recently, we discovered a problem with EFloat attributes---it seems that writing e.g. "10.0" evaluates to a double value, which then leads to a ClassCastException during assignments.
>>
>> java.lang.ClassCastException: The value of type 'class java.lang.Double' must be of type 'class java.lang.Float'
>>
>> is there any way to specify in OCL that a value should be cast to float/EFloat or do we have to provide for that in our transformation engine?
>>
>> Thanks
>>
>> Joel
>
Previous Topic:Pivot OCL
Next Topic:Problem about OCLinEcore
Goto Forum:
  


Current Time: Tue Mar 19 06:53:04 GMT 2024

Powered by FUDForum. Page generated in 0.02630 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top