eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[evaluator] Use unboxed rather than boxed model elements #1390

Closed eclipse-ocl-bot closed 2 hours ago

eclipse-ocl-bot commented 2 hours ago

| --- | --- | | Bugzilla Link | 448470 | | Status | RESOLVED FIXED | | Importance | P3 normal | | Reported | Oct 23, 2014 07:16 EDT | | Modified | Feb 01, 2015 07:23 EDT | | Blocks | 447557 | | Reporter | Ed Willink |

Description

Bug 447567 identifies a problem with a UML evaluation that navigates from an EnumerationLiteral.

An EnumerationLiteral may be produced during OCL parsing and so needs to have a 'pivot' value. But it may be a UML model element or an Ecore 'model element' that isn't even an EObject.

The current philosophy is that any evaluation value for which Java equals is unuseable must be boxed during OCL evaluation as an OCLValue and unboxed when returned to the user. EnumerationLiteralId should therefore be an OCLValue since it has 'equal' UML and Ecore variants.

Creation of boxed values can be avoided when their unboxed instances are unique. A UML EnumerationLiteral should be unique, unless a *.uml is loaded dynamically as well as the Java Ecore equivalent; surely an unrecoverable disaster? An Ecore EEnumLiteral may not be unique since ;equal' Enumerators may exist independently.

If the IdResolver is responsible for boxing/unboxing decisions the UML-IdResolver can use unboxed EnumerationLiterals, while the Ecore-IdResolver and Pivot-IdResolver use boxed.

In order to avoid the potential confusion between a boxed value from a EnumerationLiteralExp and an unboxed value from a PropertyCallExp, EnumerationLiteralExp should give the IdResolver an opportunity to unbox the Pivot EnumerationLiteralId.

Similarly boxing of Type can be avoided, which should fix the EvaluateNameVisibilityTest4.test_implicit_source failure when using the code generator caused by a computed Set{Integer} failing to compare equal to literal Set{Integer}.

To support this we must introduce a UML-IdResolver which requires an ability to identify the user's technology space at the moment a MetaModelManager is created. This will avoid some magic UML-specific code in the communal PivotIdResolver.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Oct 26, 2014 05:22

(In reply to Ed Willink from comment #0)

To support this we must introduce a UML-IdResolver which requires an ability to identify the user's technology space at the moment a MetaModelManager is created.

Yes, but while it is appropriate to impose one normalized pivot representation on all meta-models, it is not appropriate to impose just one technology space.

Where asEcoreObject seemed like an adequate way to restore legacy representation, the need for different UML representations shows that we need something more.

But even in the UML world, we may want OMG UML, with unbounded numerics, or Eclipse UML2, with '32 bit' integers and potentially both in the same application. We need to facilitate a custom IdResolver to define a custom technology space for value representations.

The IdResolver:MetaModelManager relationship must be N:1 not 1:1. Ideally, the MetaModelManager has no ability to navigate to an IdResolver at all.

Since MetaModelManger is fading away in favour of a CompleteModel, this API evolution seems like a good time to accommodate this change. Doing it directly on the current code will just incur double development costs.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Oct 30, 2014 02:57

(In reply to Ed Willink from comment #1)

(In reply to Ed Willink from comment #0)

To support this we must introduce a UML-IdResolver which requires an ability to identify the user's technology space at the moment a MetaModelManager is created.

This is non-trivial, but the ModelManager is aware of the user context and so we can determine Ecore/UML there ore easily. This will do as a short term fix; it fixes the reported repo, it avoids 6 regressions in test_uml_enums_412685 although two test verdicts need changing, an evaluation in the pivot domain now requires a pivot enumeration literal rather than a UML enumeration literal, which seems like a good move anyway.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Oct 31, 2014 10:00

(In reply to Ed Willink from comment #2)

... but the ModelManager is aware of the user context ...

The improved functionality is available in the latest maintenance and nightly builds.

Not RESOLVED since the 'correct' solution of an IdResolver-based solution is outstanding.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Dec 18, 2014 02:42

See Bug 455394.

org.eclipse.uml2.uml.internal.impl.PropertyImpl.getAggregation () returns the Ecore Enumerator for org.eclipse.uml2.uml.AggregationKind which is an EEnum not an UML EnumerationLiteral. Use of UML EnumerationLiteral is therefore unsound. They must be boxed to ensure equality of diverse representations. This will incur some conversion costs but at least removes a UML-specific irregularity.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Jan 25, 2015 13:19

The original fix to use unboxed Ecore EnumerationLiterals was reworked since UML EnumerationLiterals mus be boxed.

Backport pushed to maintenance/R5.0 for SR2. Available as 5.0.4 maintenance build.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Feb 01, 2015 07:23

Bug 447919 has been marked as a duplicate of this bug.