Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Debugging OCL constraints via java debugger
Debugging OCL constraints via java debugger [message #1067741] Wed, 10 July 2013 11:56 Go to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 94
Registered: July 2009
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 24 times)
Re: Debugging OCL constraints via java debugger [message #1067750 is a reply to message #1067741] Wed, 10 July 2013 12:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
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 Go to previous messageGo to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 94
Registered: July 2009
Member
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.


  1. Create a new oclinecore tutorial project in your workspace
  2. Set the OCL option to generate java code instead of runtime interpretion
  3. From the genmodel, generate model, edit and editor code
  4. Run the generated editor plugin as new eclipse application
  5. 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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26287
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
>
Re: Debugging OCL constraints via java debugger [message #1067770 is a reply to message #1067760] Wed, 10 July 2013 13:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
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
>>
>
Re: Debugging OCL constraints via java debugger [message #1067784 is a reply to message #1067774] Wed, 10 July 2013 14:44 Go to previous messageGo to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 94
Registered: July 2009
Member
Ed Willink wrote on Wed, 10 July 2013 10:11
Hi Ed

This is indeed an EMF issue; no OCL involvemnt.

But the model being saved has two validation errors. (Required feature
not set).


At least here, I cannot reproduce the issue if the OCL validation method is set to runtime interpretion. Then I can perfectly save a model in which required features are not set?

Re: Debugging OCL constraints via java debugger [message #1067794 is a reply to message #1067784] Wed, 10 July 2013 15:35 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
HI

Can't argue any longer.

As Ed M commented something's returning an EList that cannot be cast to
InternalEList.

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

Thanks. I've been thinking of an 'a' release. This looks like a string
candidate.

Regards

Ed Willink



On 10/07/2013 15:44, Klaas Gadeyne wrote:
> Ed Willink wrote on Wed, 10 July 2013 10:11
>> Hi Ed
>>
>> This is indeed an EMF issue; no OCL involvemnt.
>>
>> But the model being saved has two validation errors. (Required
>> feature not set).
>
>
> At least here, I cannot reproduce the issue if the OCL validation
> method is set to runtime interpretion. Then I can perfectly save a
> model in which required features are not set?
>
>
Previous Topic:[OCLinEcore] Project specific settings not taken into account for code generation
Next Topic:ClassCastException thrown when using ecore::EDouble
Goto Forum:
  


Current Time: Sun Dec 21 11:28:00 GMT 2014

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

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