Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Run-time errors in queries and templates(Errors are raised for embedded expressions but not when the expression result is stored in a variable)
Run-time errors in queries and templates [message #1462348] Wed, 05 November 2014 13:35 Go to next message
Anakreontas Mentis is currently offline Anakreontas MentisFriend
Messages: 85
Registered: October 2014
Member
In queries (and templates), the query raises a run-time error but when I substitute an expression with a variable that stores the expression result, the error disappears. The following query provides a demonstration. When I replace the expression p.componentDeclaration with the variable comp that stores the expression result, the run-time error of the first version is not raised. Why aren't the two queries equivalent?

First version:
[query private getConIndexes(p : SubPortDeclarationReference, compound : CompoundInstance, cluster : Integer, nextPorts : Set(AtomInternalPortDeclaration)) : Set(Integer) =
nextPorts->select(pp | p.forwardPortDeclaration.oclAsType(AtomExportPortDeclaration) portDeclarationReferences->includes(pp))->collect(getIndex(compound.declaration, p.componentDeclaration, cluster))
/]
raises a run-time error:
=====
org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined argument p.componentDeclaration of invocation at line 0 in Module atom for block getIndex(temp97,compound.declaration,p.componentDeclaration,cluster). Last recorded value of self was bip2.ujf.verimag.bip.port.impl.SubPortDeclarationReferenceImpl@2f97fb84. Problem found while generating the file '/home/mentis/sources/demo/./cluster1.cpp'.
at atom.getConIndexes(SubPortDeclarationReference,CompoundInstance,Integer,Set(AtomInternalPortDeclaration))(atom.mtl:0)
at atom.getConIndexes(SubPortDeclarationReference,CompoundInstance,Integer,Set(AtomInternalPortDeclaration))(atom.mtl:0)
at atom.nextPossiblyEnabledPortIndexex(ConnectorDeclaration,ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:0)
at atom.nextPossiblyEnabledPortIndexex(ConnectorDeclaration,ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:0)
at atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:0)
at atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:0)
at atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:649)
at atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:648)
at atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:614)
at atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:0)
at atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:547)
at atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:546)
at atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:519)
at connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:0)
at connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:316)
at connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:253)
at connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:232)
at connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:0)
at connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:600)
at connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:593)
at connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:567)
at generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:0)
at generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:741)
at generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:666)
at generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:665)
at generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:658)
java.lang.UnsupportedOperationException: Operation sep(String) is undefined on type org.eclipse.ocl.ecore.internal.OCLStandardLibraryImpl$1.
at org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.getExceptionOperationCallFailed(AcceleoLibraryOperationVisitor.java:1046)
.........

If I change the query into:
[query private getConIndexes(p : SubPortDeclarationReference, compound : CompoundInstance, cluster : Integer, nextPorts : Set(AtomInternalPortDeclaration)) : Set(Integer) =
let comp : ComponentDeclaration = p.componentDeclaration
in
nextPorts->select(pp | p.forwardPortDeclaration.oclAsType(AtomExportPortDeclaration) portDeclarationReferences->includes(pp))->collect(getIndex(compound.declaration, comp, cluster))
/]
no errors are raised. Unfortunately this happens quite often and I haven't discovered why. The two queries should be equivalent.
Re: Run-time errors in queries and templates [message #1462371 is a reply to message #1462348] Wed, 05 November 2014 13:55 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5421
Registered: July 2009
Senior Member
Hi

This is not an OCL issue. It is an Acceleo problem where you will find a
recent thread reporting a very similar issue.

If one form of query works, then use it.

Regards

Ed Willink


On 05/11/2014 13:35, Anakreontas Mentis wrote:
> In queries (and templates), the query raises a run-time error but when I
> substitute an expression with a variable that stores the expression
> result, the error disappears. The following query provides a
> demonstration. When I replace the expression p.componentDeclaration
> with the variable comp that stores the expression result, the run-time
> error of the first version is not raised. Why aren't the two queries
> equivalent?
>
> First version:
> [query private getConIndexes(p : SubPortDeclarationReference, compound :
> CompoundInstance, cluster : Integer, nextPorts :
> Set(AtomInternalPortDeclaration)) : Set(Integer) =
> nextPorts->select(pp |
> p.forwardPortDeclaration.oclAsType(AtomExportPortDeclaration)
> portDeclarationReferences->includes(pp))->collect(getIndex(compound.declaration,
> p.componentDeclaration, cluster))
> /] raises a run-time error:
> =====
> org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined
> argument p.componentDeclaration of invocation at line 0 in Module atom
> for block
> getIndex(temp97,compound.declaration,p.componentDeclaration,cluster).
> Last recorded value of self was
> mailto:bip2.ujf.verimag.bip.port.impl.SubPortDeclarationReferenceImpl@2f97fb84.
> Problem found while generating the file
> '/home/mentis/sources/demo/./cluster1.cpp'.
> at
> atom.getConIndexes(SubPortDeclarationReference,CompoundInstance,Integer,Set(AtomInternalPortDeclaration))(atom.mtl:0)
>
> at
> atom.getConIndexes(SubPortDeclarationReference,CompoundInstance,Integer,Set(AtomInternalPortDeclaration))(atom.mtl:0)
>
> at
> atom.nextPossiblyEnabledPortIndexex(ConnectorDeclaration,ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:0)
>
> at
> atom.nextPossiblyEnabledPortIndexex(ConnectorDeclaration,ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:0)
>
> at
> atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:0)
>
> at
> atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:0)
>
> at
> atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:649)
>
> at
> atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:648)
>
> at
> atom.generatePostExec(ConnectorDeclaration,CompoundInstance,Integer,Boolean)(atom.mtl:614)
>
> at
> atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:0)
>
> at
> atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:547)
>
> at
> atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:546)
>
> at
> atom.generateExec(ConnectorDeclaration,CompoundInstance,Integer)(atom.mtl:519)
>
> at
> connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:0)
>
> at
> connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:316)
>
> at
> connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:253)
>
> at
> connector.generateLock(ConnectorDeclaration,CompoundInstance,Integer)(connector.mtl:232)
>
> at
> connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:0)
>
> at
> connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:600)
>
> at
> connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:593)
>
> at
> connector.generateConnectorFunction(ConnectorDeclaration,CompoundInstance)(connector.mtl:567)
>
> at
> generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:0)
> at
> generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:741)
> at
> generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:666)
> at
> generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:665)
> at
> generateCluster.generateCluster(ComponentInstance)(generateCluster.mtl:658)
> java.lang.UnsupportedOperationException: Operation sep(String) is
> undefined on type org.eclipse.ocl.ecore.internal.OCLStandardLibraryImpl$1.
> at
> org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.getExceptionOperationCallFailed(AcceleoLibraryOperationVisitor.java:1046)
>
> ........
>
> If I change the query into:
> [query private getConIndexes(p : SubPortDeclarationReference, compound :
> CompoundInstance, cluster : Integer, nextPorts :
> Set(AtomInternalPortDeclaration)) : Set(Integer) =
> let comp : ComponentDeclaration = p.componentDeclaration
> in nextPorts->select(pp |
> p.forwardPortDeclaration.oclAsType(AtomExportPortDeclaration)
> portDeclarationReferences->includes(pp))->collect(getIndex(compound.declaration,
> comp, cluster))
> /] no errors are raised. Unfortunately this happens quite often and I
> haven't discovered why. The two queries should be equivalent.
Previous Topic:Custom OCL messages
Next Topic:Restrict stereotypes with constraints
Goto Forum:
  


Current Time: Tue Oct 17 02:14:26 GMT 2017

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

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