|
Re: Calling methods with enum-parameter [message #60913 is a reply to message #60875] |
Wed, 20 August 2008 12:03 |
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02205 seconds