eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[pivot] ClassCastException for constraint on static profile #1639

Open eclipse-ocl-bot opened 4 weeks ago

eclipse-ocl-bot commented 4 weeks ago

| --- | --- | | Bugzilla Link | 482143 | | Status | NEW | | Importance | P3 normal | | Reported | Nov 13, 2015 12:56 EDT | | Modified | Mar 11, 2016 12:03 EDT | | See also | 482264 | | Reporter | Ed Willink |

Description

From the OCL newsgroup "[OCL] ClassCastException for constraint on static profile" thread.

A first investigation suggests that UML2ASReferenceSwitch is not delegating correctly to Ecore2ASReferenceSwitch with the result that the base_Class.type is null causing ensuing bad things.

But this is such a fundamental problem that surely it cannot be.

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Nov 13, 2015 14:04

Problem is caused by the org.eclipse.uml2.uml.generated_package which provides a UML version of the profile in addition to org.eclipse.emf.ecore.generated_package's Ecore version.

It seems the UML version has never been triggered before.

[Why can't UML2 work out whether it uses UML or Ecore models?)

Workaround: delete the org.eclipse.uml2.uml.generated_package extension point.

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Nov 13, 2015 15:12

With just an org.eclipse.emf.ecore.generated_package, there is only the static profile so validation uses the Ecore, and Ecore2AS works correctly for

com.ecme.MyProfile.impl.MyClassImpl

With just an org.eclipse.uml2.uml.generated_package, there is also a dynamic profile so validation uses the UML, but UML2AS has a problem for

org.eclipse.uml2.uml.internal.impl.ModelImpl

Bug 482160 for the missing diagnosis.

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Nov 14, 2015 16:48

(In reply to Ed Willink from comment #1)

[Why can't UML2 work out whether it uses UML or Ecore models?)

Workaround: delete the org.eclipse.uml2.uml.generated_package extension point.

Sorry. I really don't understand what UML is trying to do with extra Ecore for UML. Not surprisingly my code adds to the mess.

There is a workaround so this is very low priority for me.

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Nov 14, 2015 17:09

(In reply to Ed Willink from comment #2)

but UML2AS has a problem for

org.eclipse.uml2.uml.internal.impl.ModelImpl

It appears that an EcoreASResource rather than UMLASResource is created, perhaps because the nsURI is ambiguous. But perhaps the EcoreASResource is correct and the failure to resolve "Class" is easily solved by pre-loading the UML metamodel.

?? has an explicit/implicit import of the UML metamodel been ignored ??

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Nov 16, 2015 06:17

(In reply to Ed Willink from comment #4)

?? has an explicit/implicit import of the UML metamodel been ignored ??

See also Bug 482264

NB UMLIdResolver::getStaticTypeOf does

metamodelManager.getASOf(Element.class, umlElement); // Needed by test_stereotypes_Bug431638

which looks suspiciously like a magic provision of an 'implicit' import.

eclipse-ocl-bot commented 4 weeks ago

By Johan Van Noten on Nov 18, 2015 04:21

Ed, you indicate that there is a workaround, but I don't really see how that would work. I tried the two alternatives mentioned below.

I restarted from the reproduction model I attached to this post: https://www.eclipse.org/forums/index.php?t=msg&th=1071796&goto=1714295&#msg_1714295.\ Each time, I retried to make my runtime model from scratch (one Class and apply the MyClass profile). The results are seen below.

I also checked the current developments on the SysML 1.4 for Mars.1. They also have both entries in their plugin.xml.

So, probably I misunderstand your suggested workaround. For now, I remain stuck on defining plain OCL validation for my static profile.\ Do you succeed in creating a working static profile when one of the two plugin.xml entries are missing?

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Nov 18, 2015 05:40

Perhaps my workaround only works in so far as it allows OCL->Validate to be used in the UML editor. More advanced usage may be a problem as you observe.

Sorry. Occasionally I look at this UML area in the evenings for a break, but I doubt that I can devote any serious time this callendar year.

eclipse-ocl-bot commented 4 weeks ago

By Johan Van Noten on Nov 18, 2015 16:39

Ed, based on your current analysis, do you judge the root cause is to be found in OCL or is it rather a more general UML2/profiles problem? Just wondering whether someone else should be put in copy on this issue.

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Nov 19, 2015 01:39

In an ideal world, the Eclipse UML2 multi-usage of embedded Ecore within UML files to define stereotypes, and the missing OMG UML stereotype application class would be revisited and clearly specified.

Eclipse OCL attempts to paper over these problems by using a normalized internal pivot representation, so that internally a better approximation to the ideal world exists.

It is OCL's empirically designed UML2AS conversion that is at the heart of most of the pivot OCL inadequacies with respect to UML.

My primary current activity is supporting the QVTi transformaton engine that will enable auto-generated Java code to perform the UML2AS conversion in accordance with an OCL-based specification. We will then know what we are doing and can do it accurately and incrementally directly solving some of the UML2AS problems and providing a form foundation for solving the rest.

That said there seems to be an underlying inadequacy in the support for 'import' that affects about three recent problems. The inadequacy needs to be understood anyway. Once understood the fix may be rather simple.

eclipse-ocl-bot commented 4 weeks ago

By Johan Van Noten on Nov 19, 2015 04:33

Sounds logical to follow a decent step-by-step approach to refactoring.\ I will put this on hold from my side till you are ready to attack this issue.\ Thanks for your feedback.

eclipse-ocl-bot commented 4 weeks ago

By Ed Willink on Jan 14, 2016 05:57

(In reply to Ed Willink from comment #5)

which looks suspiciously like a magic provision of an 'implicit' import.

See Bug 485586 which 'cured' a stupid problem with simple model hat did not provide a clue as to what the UML metamodel is.