Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Calling methods with enum-parameter
Calling methods with enum-parameter [message #60875] Wed, 20 August 2008 05:48 Go to next message
Stefan Schulze is currently offline Stefan Schulze
Messages: 70
Registered: July 2009
Member
Hi...

if I define an operation on a class in my ecore-model and give this an
enum-parameter I can't call it from an OCL-expression due to the following
exception:
> java.lang.IllegalArgumentException: argument type mismatch
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.eclipse.ocl.AbstractEvaluationEnvironment.callOperation( AbstractEvaluationEnvironment.java:185)
> at
> org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperati on(EcoreEvaluationEnvironment.java:85)
> at
> org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperati on(EcoreEvaluationEnvironment.java:1)
> at
> org.eclipse.ocl.internal.evaluation.EvaluationVisitorImpl.vi sitOperationCallExp(EvaluationVisitorImpl.java:172)
> at
> org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(Opera tionCallExpImpl.java:336)
> at
> org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(Ab stractEvaluationVisitor.java:223)
> at
> org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(Query Impl.java:120)

This exception is caused because you call the java-method with an
EEnumLiteral as parameter, but the enum-type is expected.


Steps for reproduction:
1. Use the following Ecore-model:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
nsURI="test" nsPrefix="test">
<eClassifiers xsi:type="ecore:EClass" name="Clazz">
<eOperations name="foo">
<eParameters name="param" eType="#//TestEnum"/>
</eOperations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="TestEnum">
<eLiterals name="TestLiteral"/>
</eClassifiers>
</ecore:EPackage>

2. Generate the model-, edit- and editorcode. You not even have to implement
the generated method.
3. Start a new Eclipse-instance with the generated plugins.
4. Create a new Test Model.
5. Call the expression "foo(TestEnum::TestLiteral)" on the Clazz in the
Interactive OCL Interpreter.

If you change the method in the model to accept an JavaObject-parameter and
set an breakpoint in the generaetd method, you can see that an EEnumLiteral
is passed to the method.

I only tried this on OCL 1.1.2 because I don't have 1.2.x with all the
dependencies. Is it probably already fixed in 1.2.x? I couldn't find an
issue in BugZilla.

Stefan
Re: Calling methods with enum-parameter [message #60913 is a reply to message #60875] Wed, 20 August 2008 12:03 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

Hi, Stefan,

I doubt that this is fixed in the 1.2 release. I would very much like
to fix it for 1.2.2; would you mind raising a bug?

Thanks!

Stefan Schulze wrote:
> Hi...
>
> if I define an operation on a class in my ecore-model and give this an
> enum-parameter I can't call it from an OCL-expression due to the following
> exception:
>> java.lang.IllegalArgumentException: argument type mismatch
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> at java.lang.reflect.Method.invoke(Unknown Source)
>> at
>> org.eclipse.ocl.AbstractEvaluationEnvironment.callOperation( AbstractEvaluationEnvironment.java:185)
>> at
>> org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperati on(EcoreEvaluationEnvironment.java:85)
>> at
>> org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperati on(EcoreEvaluationEnvironment.java:1)
>> at
>> org.eclipse.ocl.internal.evaluation.EvaluationVisitorImpl.vi sitOperationCallExp(EvaluationVisitorImpl.java:172)
>> at
>> org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(Opera tionCallExpImpl.java:336)
>> at
>> org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(Ab stractEvaluationVisitor.java:223)
>> at
>> org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(Query Impl.java:120)
>
> This exception is caused because you call the java-method with an
> EEnumLiteral as parameter, but the enum-type is expected.
>
>
> Steps for reproduction:
> 1. Use the following Ecore-model:
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
> nsURI="test" nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="Clazz">
> <eOperations name="foo">
> <eParameters name="param" eType="#//TestEnum"/>
> </eOperations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="TestEnum">
> <eLiterals name="TestLiteral"/>
> </eClassifiers>
> </ecore:EPackage>
>
> 2. Generate the model-, edit- and editorcode. You not even have to implement
> the generated method.
> 3. Start a new Eclipse-instance with the generated plugins.
> 4. Create a new Test Model.
> 5. Call the expression "foo(TestEnum::TestLiteral)" on the Clazz in the
> Interactive OCL Interpreter.
>
> If you change the method in the model to accept an JavaObject-parameter and
> set an breakpoint in the generaetd method, you can see that an EEnumLiteral
> is passed to the method.
>
> I only tried this on OCL 1.1.2 because I don't have 1.2.x with all the
> dependencies. Is it probably already fixed in 1.2.x? I couldn't find an
> issue in BugZilla.
>
> Stefan
Re: Calling methods with enum-parameter [message #61031 is a reply to message #60913] Wed, 20 August 2008 21:52 Go to previous message
Stefan Schulze is currently offline Stefan Schulze
Messages: 70
Registered: July 2009
Member
Hi Christian,

I raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=244755.

Stefan
Previous Topic:Re: downloading MDT-OCLTools
Next Topic:..*-associations should be Set by default?
Goto Forum:
  


Current Time: Tue Oct 21 00:32:51 GMT 2014

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

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