Skip to main content



      Home
Home » Modeling » UML2 » Accessing value of inherited tags
Accessing value of inherited tags [message #1871460] Thu, 26 September 2024 02:50 Go to next message
Eclipse UserFriend
I cannot succeed in getting value given to tags that are inherited by an applied stereotype.

The SysML::Requirements::Trace stereotype inherits from the SysML::Blocks:DirectedRelationshipPorpertyPath abstract stereotype that has the tag "sourceContext" defined (among others).

However, when I try to get the value of sourceContext from an applied "Trace" stereotype using the EMF getValue operation, I got the following error message:

org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.IllegalArgumentException: sourceContext
at public abstract java.lang.Object org.eclipse.uml2.uml.Element.getValue(org.eclipse.uml2.uml.Stereotype,java.lang.String)

When I use the very same operation with "owned" tags (from other stereotypes) it works well.

How can I access the value inherited tags?
Re: Accessing value of inherited tags [message #1871466 is a reply to message #1871460] Thu, 26 September 2024 03:44 Go to previous messageGo to next message
Eclipse UserFriend
Testing further, it appears that the getValue operation works as expected when used in the Interactive OCL console... While the problem happens when I used it within an ATL script!
Re: Accessing value of inherited tags [message #1871487 is a reply to message #1871466] Thu, 26 September 2024 06:58 Go to previous messageGo to next message
Eclipse UserFriend
The type inference in non-trivial expressions is not always perfect. If it works sometimes you may find that simplifying expressions with let-variables can help.

You don't mention which OCL console you use; you may well be using a different OCL parser.
Re: Accessing value of inherited tags [message #1871493 is a reply to message #1871487] Thu, 26 September 2024 10:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,
Thank you for your reply. I tested it with the so-called 'Interactive OCL' console and with this one it works fine. Actually - so far - I experience this issue with ATL only, and even not with all the stereotypes, only with some of them. So it would be really useful to me to have a look at the code of the getValue operation to see under what condition the "IllegalArgumentException" is thrown.
Re: Accessing value of inherited tags [message #1871508 is a reply to message #1871493] Fri, 27 September 2024 01:16 Go to previous messageGo to next message
Eclipse UserFriend
Eclipse OCL provides an "Interactive OCL" console for older Classic Eclipse OCL (used by QVTo).
Eclipse OCL provides an "Interactive Xtext OCL" console for the newer Pivot-based Eclipse OCL (used by Papyrus, QVTd).
ATL has an independent 'OCL' but I suspect no console.
Acceleo has migrated from Classic OCL to AQL and has an interactive console (used by Sirius)
Epsilon may well have a console for EOL.
Support for stereotypes is very poorly specified by OMG however there are sufficient hints to allow the Pivot-based OCL to prototype a type-safe solution. Other implementations rely on exposing the Eclipse UML2 Java API and so lose source syntax checking and type safety as Object/EList are polymorphised by the getValue return. This combined with the difficulty of correctly spelling stereotype names for the Java API can make for a difficult development/debugging time.
If you have an IAE then debugging should be straightforward; run in a nested Eclipse and set a breakpoint on the IAE. If you're a bit 'cleverer' you may attach a second Eclipse to remotely debug your first Eclipse.

Re: Accessing value of inherited tags [message #1871511 is a reply to message #1871508] Fri, 27 September 2024 01:58 Go to previous messageGo to next message
Eclipse UserFriend
Yes, it looks like a debugger will be the only mean for really understanding where the issue is.
Thanks.
Re: Accessing value of inherited tags [message #1871520 is a reply to message #1871511] Fri, 27 September 2024 08:35 Go to previous messageGo to next message
Eclipse UserFriend
Yes, it looks like a debugger will be the only mean for really understanding where the issue is.
Thanks.
Re: Accessing value of inherited tags [message #1871523 is a reply to message #1871520] Fri, 27 September 2024 11:47 Go to previous messageGo to next message
Eclipse UserFriend
After investigations, I have identified that the cause of the exception if that the getValue operation does not retrieve the tag value within the list of the structural features of the EClass corresponding to the stereotype applied (despite they are actually defined in the UML stereotype).

The exception explicitly points the org.eclipse.uml2.uml.Element.getValue operation as its source. Hence, I wonder whether the "Interactive OCL" console (i.e. the first in the list Ed's gave earlier in this topic) uses another implementation of this operation or, if its' not the case, why the problem does not appears with this console but when I call it within an ATL script (and in addition only with some stereotypes).
Re: Accessing value of inherited tags [message #1871529 is a reply to message #1871523] Fri, 27 September 2024 15:21 Go to previous message
Eclipse UserFriend
IMHO the Classic Eclipse OCL handling of operations such as getValue() is broken; there are multiple compensations for the Object/EList polymorphism that I could not understand and I was pretty sure were not right and could not be corrected without breaking APIs; just one of the reasons for rationalizing with the Pivot-based Eclipse OCL. Since coding getValue() is so hard I suspect that other tools have rival compensations. As I suggested earlier, imposing a tight type discipline with let-variables and oclAsType casts may enable you to gain some control.
Previous Topic:Reading SysML model from XMI
Goto Forum:
  


Current Time: Sun Jul 20 12:59:26 EDT 2025

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

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

Back to the top