Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Papyrus static profile Java code issue with "*" or "unlimited value" handling(Problem found regarding UML::UnlimitedNatural handling being mixed with UML::Integer in such a way that the "*" or "unlimited value" isn't being handled corrected in the Java gener)
Papyrus static profile Java code issue with "*" or "unlimited value" handling [message #1837469] Sun, 31 January 2021 01:38 Go to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Problem found regarding UML::UnlimitedNatural handling being mixed with UML::Integer in such a way that the "*" or "unlimited value" isn't being handled corrected in the Java generated OCL expressions.

Attached is tar file ValidationProblem6.tar.gz containing the example static profile wrapped in a Git repo called "com.validationproblem.profile".

Testing was done with 2020-06 Eclipse release - Papyrus 4.8.0 (version installed when installing Papyrus SysML 1.6 Feature through the Marketplace).

In the stereotype Stereotype1 I have added properties:


  • +u: UnlimitedNatural[1] - free for user to set after applying stereotype
  • +/isUnlimited: Boolean[1] - derived property with OCL expression "self.u = *"
  • +/copy_u: UnlimitedNatural[1] - derived property with OCL expression "self.u"


When I generate Java code using genmodel with setting "Use Delegates" I get the Java code generated as shown in the attached profile code and pasted here in the ticket below.

As you can see the generated functions getU returns 'u' as an 'int' literal, which means the UML notion of "*" or "unlimited value" is lost! Doesn't seem to be represented even?

You can also see the function setU set by 'int' again same problem/limitation.

Function isUnlimited performs the OCL expression "self.u = *" check by first casting the value of u to "int" via getU

ValueUtil however seems to have an unlimited value implementation - so casting to "int" first seems problematic to me:
public static final @NonNull UnlimitedValue UNLIMITED_VALUE = new UnlimitedValueImpl();


In isUnlimited generated function I even get a Java build error for trying to assign a UnlimitedNaturalValue using an IntegerValue:
final /*@NonInvalid*/ UnlimitedNaturalValue BOXED_u = ValueUtil.integerValueOf(u);


It seems UML::UnlimitedNatural handling is mixed with UML::Integer in such a way that the "*" or "unlimited value" isn't being handled corrected in the Java generated OCL expressions.
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public int getU() {
    return u;
}

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setU(int newU) {
    int oldU = u;
    u = newU;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ValidationProblemPackage.STEREOTYPE1__U, oldU, u));
}

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean isUnlimited() {
    /**
    * self.u = *
    */
    final /*@NonInvalid*/ int u = this.getU();
    final /*@NonInvalid*/ UnlimitedNaturalValue BOXED_u = ValueUtil.integerValueOf(u);
    final /*@NonInvalid*/ boolean eq = BOXED_u.equals(ValueUtil.UNLIMITED_VALUE);
    return eq;
}

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public int getCopy_u() {
    /**
    * self.u
    */
    final /*@NonInvalid*/ int u = this.getU();
    return u;
}

[Updated on: Sun, 31 January 2021 01:41]

Report message to a moderator

Re: Papyrus static profile Java code issue with "*" or "unlimited value" handlin [message #1837474 is a reply to message #1837469] Sun, 31 January 2021 08:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

As a mathematician you might think that UnlimitedNatural formed part of the real > integer > natural domains, and for a while I tried to make UnlimitedNatural a natural. But it only makes sense if * has an integer/real representation, for which infinity is very available and arguably very appropriate and currently an omission. Members of the UML specification task force have been very resistant to generalizing * as infinity and so UnlimitedNatural cannot be a sub-domain of Integer. Consequently I now take the very narrow view that an UnlimitedNatural is a wacky enumeration of the non-negative Integers with an extra unlimited value. UnlimitedNatural should ONLY be used to represent the values of a multiplicity upper bound. Conversion between UnlimitedNatural and Integer is no longer possible by inheritamce and should in principle be explicit although a little automated conversion is tolerated to avoid legacy issues.

That said, the Java code should never have compilation errors.

Regards

Ed Willink
Re: Papyrus static profile Java code issue with "*" or "unlimited value" handlin [message #1837475 is a reply to message #1837474] Sun, 31 January 2021 09:49 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I guess it depends on the how the underlying structures of the Java code is created and I'm not too familiar with them, but I would have made UnlimitedNatural inherit from Integer and a special UnlimitedValue inherit from UnlimitedNatural whereby all operations and funcitons of the UnlimitedNatural can be specialized for the UnlimitedValue.

However, if we are discussing at a UML level - then ultimately I do agree with you that the UnlimitedValue should be generalized for Integer and Real values; then even a negative unlimited-value can be in question.

In the meantime, there is a Java compile issue - when dealing with the basic OCL expressions I've given in my simple example with uploaded project to demonstrate it.

But I'm getting the message that the UnlimitedNatural isn't really supported for general use in the current architecture and I should refrain from trying to do anything special with it...



Best regards,
Deniz
Re: Papyrus static profile Java code issue with "*" or "unlimited value" handlin [message #1837476 is a reply to message #1837475] Sun, 31 January 2021 10:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

That inheritance was in the Eclipse OCL code and in the OCL 2.3 specification., It is now removed from both since it was unsound.

Regards

Ed Willink
Re: Papyrus static profile Java code issue with "*" or "unlimited value" handlin [message #1837477 is a reply to message #1837476] Sun, 31 January 2021 10:29 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I see, probably more productive trying to get a better resolution from UML level first. Since clearly model based design is pushing forwards into SysML and other domains that also require good mathematical support at the fundamental UML primitives levels.

In the meantime it shouldn't be too hard to design around or away from UnlimitedNaturals... and to leave that as a single application wonder, i.e. that for upper limits of multiplicity.



Best regards,
Deniz
Re: Papyrus static profile Java code issue with "*" or "unlimited value" handlin [message #1837510 is a reply to message #1837477] Mon, 01 February 2021 11:41 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

I don't agree with your analysis. In Ecore, we have the tradition that -1 means *, so that is the API that the Pivot CG must observe. Many integer values do therefore pass unchanged.

However once I try to put some more JUnit testing together, the support for UnlimitedNatural in Ecore seems quite dreadful. But again I'm puzzled; your examples use int whereas mine fail on EBigInteger.

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

Regards

Ed Willink
Re: Papyrus static profile Java code issue with "*" or "unlimited value" handlin [message #1837638 is a reply to message #1837510] Wed, 03 February 2021 14:09 Go to previous message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I didn't know -1 was used to represent * in Ecore. I guessed something like that could be the case and numerical trickery shouldn't be an issue either I guess...

Let's see how the bug analysis goes.



Best regards,
Deniz
Previous Topic:Papyrus 2020-12 release (5.0.0), SysML 1.6, StringMatcher issue
Next Topic:Static profile OCL expressions referring extension_* results in exception throwing Java code
Goto Forum:
  


Current Time: Mon Sep 23 15:40:59 GMT 2024

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

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

Back to the top