Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » [OCL Console] Access Package of model
[OCL Console] Access Package of model [message #999186] Fri, 11 January 2013 14:34 Go to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

I try to derive annotations which I attached to the root package of my ecore model. To do so I navigate from the root model element of my model to the instance of the package by using .eContainer(). From this I want to get the meta model class to retrieve the annotations from. For this I use .eClass(). This command, however, throws an Exception. How can I get around this problem.

Ralph

java.lang.NullPointerException
	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:205)
	at org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperation(EcoreEvaluationEnvironment.java:165)
	at org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperation(EcoreEvaluationEnvironment.java:1)
	at org.eclipse.ocl.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:261)
	at org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:390)
	at org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(AbstractEvaluationVisitor.java:248)
	at org.eclipse.ocl.OCL.evaluate(OCL.java:456)
	at org.eclipse.ocl.examples.interpreter.console.OCLConsolePage.evaluate(OCLConsolePage.java:468)
	at org.eclipse.ocl.examples.interpreter.console.OCLConsolePage$InputKeyListener.keyPressed(OCLConsolePage.java:646)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:167)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1521)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4640)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4528)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	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.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Re: [OCL Console] Access Package of model [message #999205 is a reply to message #999186] Fri, 11 January 2013 14:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Without any form of repro it is very difficult to know why the
invocation of a Java Method bombs. I can just guess that you are using
an inappropriate data type, argument list or multiplicity.

You could try using the Xtext OCL Console instead, where the problem
will almost certainly be at least a little different and might have a
better diagnostic.

Regards

Ed Willoink

On 11/01/2013 14:34, Ralph Gerbig wrote:
> Hi,
>
> I try to derive annotations which I attached to the root package of my
> ecore model. To do so I navigate from the root model element of my
> model to the instance of the package by using .eContainer(). From this
> I want to get the meta model class to retrieve the annotations from.
> For this I use .eClass(). This command, however, throws an Exception.
> How can I get around this problem.
>
> Ralph
>
>
> java.lang.NullPointerException
> 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:205)
> at
> org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperation(EcoreEvaluationEnvironment.java:165)
> at
> org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperation(EcoreEvaluationEnvironment.java:1)
> at
> org.eclipse.ocl.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:261)
> at
> org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:390)
> at
> org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(AbstractEvaluationVisitor.java:248)
> at org.eclipse.ocl.OCL.evaluate(OCL.java:456)
> at
> org.eclipse.ocl.examples.interpreter.console.OCLConsolePage.evaluate(OCLConsolePage.java:468)
> at
> org.eclipse.ocl.examples.interpreter.console.OCLConsolePage$InputKeyListener.keyPressed(OCLConsolePage.java:646)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:167)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100)
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1521)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4640)
> at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:4528)
> at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923)
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
> at
> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
> 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.equinox.launcher.Main.invokeFramework(Main.java:629)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
>
Re: [OCL Console] Access Package of model [message #999211 is a reply to message #999205] Fri, 11 January 2013 15:10 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi Ed,

thanks for your reply. The statement I use on Interactive Console is

self.oclAsType(ecore::EObject).eContainer().eClass()


the XText console is already breaking when doing

self.oclAsType(ecore::EObject) with the message

Quote:

Evaluating:
self.oclAsType(ecore::EObject)
Results:
Incompatible argument type 'ecore::EObject'
java.lang.NullPointerException


Do you know how I can cast to EObject with the XText console?

Ralph
Re: [OCL Console] Access Package of model [message #999532 is a reply to message #999211] Sat, 12 January 2013 10:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

With the Interactive OCL Console you need to specify that your objects
extend EObject. You can do this interactively using the
Window->Preferences->OCL->Ecore and UML bindings option. The final
preference is the "Static instance for the implicit-root class option".
Select EObject rather than None from the pull-down menu.

============

With the Interactive Xtext OCL Console you can use prototypes for new
OCL functions.

self.oclContainer().oclType()

You can only cast to EObject if EObject is declared in your metamodel as
a supertype. If so you can do


self.oclAsType(_'http://www.eclipse.org/emf/2002/Ecore'::EObject).eContainer()

or if 'ecore' is declared

self.oclAsType(ecore::EObject).eContainer()

Regards

Ed Willink


On 11/01/2013 15:10, Ralph Gerbig wrote:
> Hi Ed,
>
> thanks for your reply. The statement I use on Interactive Console is
>
>
> self.oclAsType(ecore::EObject).eContainer().eClass()
>
>
> the XText console is already breaking when doing
>
> self.oclAsType(ecore::EObject) with the message
>
> Quote:
>> Evaluating:
>> self.oclAsType(ecore::EObject)
>> Results:
>> Incompatible argument type 'ecore::EObject'
>> java.lang.NullPointerException
>
>
> Do you know how I can cast to EObject with the XText console?
>
> Ralph
Re: [OCL Console] Access Package of model [message #999921 is a reply to message #999532] Sun, 13 January 2013 12:38 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi Ed,

thanks for your reply. I solved the problem by doing

self.oclAsType(ecore::EObject).eClass().ePackage
.

About interactive console:

The "Static instance for the implicit-root class option" entry is null and not EObject in my case but I can still do the cast. Is this intended or shall I open a bug on this?

About XText Console:

The code completition does not show functions like oclContainer. Where can I find an overvier of all these functions. Is there a meta-model where I can see these functions?

Quote:
You can only cast to EObject if EObject is declared in your metamodel as
a supertype.


I always thought EObject would be the implicit super type of all EMF Objects but this seems to not apply to OCL. What could I do to get all EMF operations available without introducing things like EObject into my meta model? Will all eXXX() functions become a oclXXX counterpart in future?

Thanks,

Ralph
Re: [OCL Console] Access Package of model [message #999927 is a reply to message #999921] Sun, 13 January 2013 12:56 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You 'can' cast to EObject but you get a run-time failure without the
implicit root option. Perhaps therew should be a validation warning.

The library functions are all in the documentation! Help->Contents->OCL
Documentation->OCL Standard Library.

If you are using a Kepler milestone release, please raise a Bugzilla
about oclContainer() completion.

EObject stopped being the modeled ancestor of all EObjects in EMF at
Helios M4. Nothing to do with OCL. It was a side effect of the
introduction of eInvoke support for which it was considered that
imposing a full set of EObject EOperation literals on every class of
every model was undesirable. Actually modeling-wise this was a bug fix,
since EObject should never have been visible when not present in the
user's model.

Regards

Ed Willink

On 13/01/2013 12:38, Ralph Gerbig wrote:
> Hi Ed,
>
> thanks for your reply. I solved the problem by doing
> self.oclAsType(ecore::EObject).eClass().ePackage.
>
> About interactive console:
>
> The "Static instance for the implicit-root class option" entry is null
> and not EObject in my case but I can still do the cast. Is this
> intended or shall I open a bug on this?
>
> About XText Console:
>
> The code completition does not show functions like oclContainer. Where
> can I find an overvier of all these functions. Is there a meta-model
> where I can see these functions?
>
> Quote:
>> You can only cast to EObject if EObject is declared in your metamodel
>> as a supertype.
>
>
> I always thought EObject would be the implicit super type of all EMF
> Objects but this seems to not apply to OCL. What could I do to get all
> EMF operations available without introducing things like EObject into
> my meta model? Will all eXXX() functions become a oclXXX counterpart
> in future?
>
> Thanks,
>
> Ralph
Previous Topic:[OCLinEcore] eReference eKeys eOpposite
Next Topic:[Announce] Eclipse OCL 4.0.2 (Juno) SR2 RC1 is now available
Goto Forum:
  


Current Time: Tue Apr 16 06:48:14 GMT 2024

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

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

Back to the top