Home » Modeling » OCL » Debugging OCL constraints via java debugger
Debugging OCL constraints via java debugger [message #1067741] |
Wed, 10 July 2013 11:56 |
Klaas Gadeyne Messages: 165 Registered: July 2009 |
Senior Member |
|
|
Hi,
[version: kepler release]
I was trying to debug an OCL constraint via the java debugger as described <http://help.eclipse.org/kepler/topic/org.eclipse.ocl.doc/help/HowDoesItWork.html?cp=37_0_2_2#Debugging>.
So I took the OCLinEcore library tutorial project, set the OCL global option "Realisation of OCL embedded within Ecore models" to "Generate Java Code", and generated the model, edit, and editor code. Running/Debugging the generated oclinecoretutorial.editor plugin as an eclipse application allows me create a new 'tutorial model', in which I create some books and members. However, when I create a 'Loan' object and try to fill or modify the "Member" or "Book" property (example model attached), I get the following exception while saving the model:
java.lang.ClassCastException: org.eclipse.emf.common.util.BasicEList cannot be cast to org.eclipse.emf.ecore.util.InternalEList
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.sameDocMany(XMLSaveImpl.java:2623)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1361)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1219)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2711)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1176)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1037)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany(XMLSaveImpl.java:2412)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1548)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1219)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2711)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XMLSaveImpl.java:678)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:586)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:251)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:365)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfChangedWithMemoryBuffer(ResourceImpl.java:1144)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:985)
at tutorial.presentation.TutorialEditor$18.execute(TutorialEditor.java:1497)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
When I use the runtime OCL interpreter for validation, the exception doesn't occur. Am I doing something wrong, or is there a problem with the generated java code?
-
Attachment: My.tutorial
(Size: 0.41KB, Downloaded 117 times)
|
|
|
Re: Debugging OCL constraints via java debugger [message #1067750 is a reply to message #1067741] |
Wed, 10 July 2013 12:47 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
You don't give me nearly enough to work on, and what you do provide is
dubious.
How can "However, when I create a 'Loan' object and try to fill or
modify the "Member" or "Book" property (example model attached)"
possibly lead to a saveFeatures problem?
You are not doing what you are describing.
Regards
Ed Willink
On 10/07/2013 12:56, Klaas Gadeyne wrote:
> Hi,
>
> [version: kepler release]
>
> I was trying to debug an OCL constraint via the java debugger as described<http://help.eclipse.org/kepler/topic/org.eclipse.ocl.doc/help/HowDoesItWork.html?cp=37_0_2_2#Debugging>.
>
> So I took the OCLinEcore library tutorial project, set the OCL global option "Realisation of OCL embedded within Ecore models" to "Generate Java Code", and generated the model, edit, and editor code. Running/Debugging the generated oclinecoretutorial.editor plugin as an eclipse application allows me create a new 'tutorial model', in which I create some books and members. However, when I create a 'Loan' object and try to fill or modify the "Member" or "Book" property (example model attached), I get the following exception while saving the model:
>
>
> java.lang.ClassCastException: org.eclipse.emf.common.util.BasicEList cannot be cast to org.eclipse.emf.ecore.util.InternalEList
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.sameDocMany(XMLSaveImpl.java:2623)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1361)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1219)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2711)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1176)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1037)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany(XMLSaveImpl.java:2412)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1548)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1219)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2711)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XMLSaveImpl.java:678)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:586)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:251)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:365)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfChangedWithMemoryBuffer(ResourceImpl.java:1144)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:985)
> at tutorial.presentation.TutorialEditor$18.execute(TutorialEditor.java:1497)
> at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
> at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
> at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
> at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
>
>
> When I use the runtime OCL interpreter for validation, the exception doesn't occur. Am I doing something wrong, or is there a problem with the generated java code?
|
|
|
Re: Debugging OCL constraints via java debugger [message #1067760 is a reply to message #1067750] |
Wed, 10 July 2013 13:23 |
Klaas Gadeyne Messages: 165 Registered: July 2009 |
Senior Member |
|
|
Ed Willink wrote on Wed, 10 July 2013 08:47Hi
You don't give me nearly enough to work on, and what you do provide is
dubious.
Would you prefer that I attach the generated plugins too? I didn't do that because it seemed faster to me just generating these yourself from the genmodel?
Are you missing something else in order to reproduce the issue?
Quote:
How can "However, when I create a 'Loan' object and try to fill or
modify the "Member" or "Book" property (example model attached)"
possibly lead to a saveFeatures problem?
The exception occurs while saving the model, not when modifying it (maybe there is something fishy with my english, but that is what I meant with " I get the following exception while saving the model" in my original post?
Quote:
You are not doing what you are describing.
Let's try to make it simpler. Forget the attachment.
- Create a new oclinecore tutorial project in your workspace
- Set the OCL option to generate java code instead of runtime interpretion
- From the genmodel, generate model, edit and editor code
- Run the generated editor plugin as new eclipse application
- In the runtime eclipse session
- Create a project with a new "tutorial" model my.tutorial, and a library l as root object.
- populate the model with a book b1, a member m1 and a loan l1
- Save the model (everything goes fine)
- Now select the l1 object, and set its book property to the b1 object
- Save the model
-> exception occurs
|
|
|
Re: Debugging OCL constraints via java debugger [message #1067765 is a reply to message #1067760] |
Wed, 10 July 2013 13:35 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
It looks to me like some multi-valued feature is returning an EList that
doesn't also implement InternalEList (and probably not
EStructuralFeature.Setting either). That's likely obvious in the
generated getter for the multi-valued feature involved in the exception...
On 10/07/2013 3:23 PM, Klaas Gadeyne wrote:
> Ed Willink wrote on Wed, 10 July 2013 08:47
>> Hi
>>
>> You don't give me nearly enough to work on, and what you do provide
>> is dubious.
>
>
> Would you prefer that I attach the generated plugins too? I didn't do
> that because it seemed faster to me just generating these yourself
> from the genmodel?
> Are you missing something else in order to reproduce the issue?
>
> Quote:
>> How can "However, when I create a 'Loan' object and try to fill or
>> modify the "Member" or "Book" property (example model attached)"
>> possibly lead to a saveFeatures problem?
>
>
> The exception occurs while saving the model, not when modifying it
> (maybe there is something fishy with my english, but that is what I
> meant with " I get the following exception while saving the model" in
> my original post?
>
> Quote:
>> You are not doing what you are describing.
>
>
> Let's try to make it simpler. Forget the attachment.
>
>
> Create a new oclinecore tutorial project in your workspace
> Set the OCL option to generate java code instead of runtime
> interpretion From the genmodel, generate model, edit and editor code
> Run the generated editor plugin as new eclipse application
> In the runtime eclipse session
>
> Create a project with a new "tutorial" model my.tutorial, and a
> library l as root object.
> populate the model with a book b1, a member m1 and a loan l1
> Save the model (everything goes fine)
> Now select the l1 object, and set its book property to the b1 object
> Save the model
>
>
>
> -> exception occurs
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Debugging OCL constraints via java debugger [message #1067770 is a reply to message #1067760] |
Wed, 10 July 2013 13:52 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
Sorry. Completely missed the attachment, which you didn't reference, so
it all seemed superficial.
Plenty to work on now.
Regards
Ed Willink
On 10/07/2013 14:23, Klaas Gadeyne wrote:
> Ed Willink wrote on Wed, 10 July 2013 08:47
>> Hi
>>
>> You don't give me nearly enough to work on, and what you do provide
>> is dubious.
>
>
> Would you prefer that I attach the generated plugins too? I didn't do
> that because it seemed faster to me just generating these yourself
> from the genmodel?
> Are you missing something else in order to reproduce the issue?
>
> Quote:
>> How can "However, when I create a 'Loan' object and try to fill or
>> modify the "Member" or "Book" property (example model attached)"
>> possibly lead to a saveFeatures problem?
>
>
> The exception occurs while saving the model, not when modifying it
> (maybe there is something fishy with my english, but that is what I
> meant with " I get the following exception while saving the model" in
> my original post?
>
> Quote:
>> You are not doing what you are describing.
>
>
> Let's try to make it simpler. Forget the attachment.
>
>
> Create a new oclinecore tutorial project in your workspace
> Set the OCL option to generate java code instead of runtime
> interpretion From the genmodel, generate model, edit and editor code
> Run the generated editor plugin as new eclipse application
> In the runtime eclipse session
>
> Create a project with a new "tutorial" model my.tutorial, and a
> library l as root object.
> populate the model with a book b1, a member m1 and a loan l1
> Save the model (everything goes fine)
> Now select the l1 object, and set its book property to the b1 object
> Save the model
>
>
>
> -> exception occurs
>
|
|
|
Re: Debugging OCL constraints via java debugger [message #1067774 is a reply to message #1067765] |
Wed, 10 July 2013 14:11 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi Ed
This is indeed an EMF issue; no OCL involvemnt.
But the model being saved has two validation errors. (Required feature
not set).
To what extent is EMF required to be able to save invalid models?
Sometimes it might be helpful, but in general it will not always be
possible.
In this case the Sample Reflective Ecore Editor correctly catches the
Save failure.
So I see an enhancement request to encourage the user to try a Validate
before saving.
And a bug; the failed save clears the editor dirty flag.
Regards
Ed Willink
On 10/07/2013 14:35, Ed Merks wrote:
> It looks to me like some multi-valued feature is returning an EList
> that doesn't also implement InternalEList (and probably not
> EStructuralFeature.Setting either). That's likely obvious in the
> generated getter for the multi-valued feature involved in the
> exception...
>
>
>
> On 10/07/2013 3:23 PM, Klaas Gadeyne wrote:
>> Ed Willink wrote on Wed, 10 July 2013 08:47
>>> Hi
>>>
>>> You don't give me nearly enough to work on, and what you do provide
>>> is dubious.
>>
>>
>> Would you prefer that I attach the generated plugins too? I didn't
>> do that because it seemed faster to me just generating these yourself
>> from the genmodel?
>> Are you missing something else in order to reproduce the issue?
>>
>> Quote:
>>> How can "However, when I create a 'Loan' object and try to fill or
>>> modify the "Member" or "Book" property (example model attached)"
>>> possibly lead to a saveFeatures problem?
>>
>>
>> The exception occurs while saving the model, not when modifying it
>> (maybe there is something fishy with my english, but that is what I
>> meant with " I get the following exception while saving the model" in
>> my original post?
>>
>> Quote:
>>> You are not doing what you are describing.
>>
>>
>> Let's try to make it simpler. Forget the attachment.
>>
>>
>> Create a new oclinecore tutorial project in your workspace
>> Set the OCL option to generate java code instead of runtime
>> interpretion From the genmodel, generate model, edit and editor code
>> Run the generated editor plugin as new eclipse application
>> In the runtime eclipse session
>>
>> Create a project with a new "tutorial" model my.tutorial, and a
>> library l as root object.
>> populate the model with a book b1, a member m1 and a loan l1
>> Save the model (everything goes fine)
>> Now select the l1 object, and set its book property to the b1 object
>> Save the model
>>
>>
>>
>> -> exception occurs
>>
>
|
|
| | |
Goto Forum:
Current Time: Wed Sep 25 07:11:09 GMT 2024
Powered by FUDForum. Page generated in 0.04958 seconds
|