Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 388232

Summary: UML Profile Metaclass extension not work since eclipse juno
Product: [Modeling] M2T Reporter: Michael Fraefel <mfr>
Component: XpandAssignee: Karsten Thoms <karsten.thoms>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jochen.schmich
Version: 1.2.2Flags: karsten.thoms: kepler+
Target Milestone: M4   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Sample project none

Description Michael Fraefel CLA 2012-08-28 10:10:59 EDT
Created attachment 220394 [details]
Sample project

Hi

We use xpand to transform uml models to java code. For that we defined our own uml profile with stereotypes. Since we upgraded to eclipse juno, our stereotypes not match anymore the extended metaclass. I tried it as well with a fresh simple example project. It doesn’t work.

In the attachment I have my example project. As you can see, the line 5 in NewXtendFile.ext has an error. But the line 8 doesn’t have it. The MyClass extends Class and should as well have the property name. Or I am wrong?

Thanks for your help.
Comment 1 Jochen Schmich CLA 2012-08-29 09:58:36 EDT
Like with Bug 385174 it looks like the changes made to org.eclipse.uml2.uml in version 4.0 have negative effects on Xtend UML Typesystem (while this is not a bug of Xtend itself).
Your issue occurs because UML Typesystem fails to retrieve the corresponding Type of the extended metaclass in order to gain access to its features (like 'name' for example).

The Stereotype is usually converted into the internal representation by the ProfileMetaModel at some point. This is also done for the Metaclass - conversion is handled by a different typesystem, though. And this seems to be an important detail:
The Metaclass is handled by Emf(Registry)MetaModel and registered via its qualified name "uml::Class" (while "uml" is the name of the EPackage in this case).

When the instance of org.eclipse.xtend.typesystem.uml2.profile.StereotypeType (the internal representation of Stereotypes) is asked for its supertypes, the ProfileMetaModel tries to lookup the internal representation of the Metaclass and add it to the list of supertypes in order to make the Stereotype inherit its attributes. This is the point, where the mechanism silently fails: The lookup routine uses a different way to compute the qualified name than the EmfRegistryMetaModel used to - the method org.eclipse.xtend.typesystem.uml2.profile.StereotypeType.getFullName(Object) now returns "UML::Class" instead of "uml::Class".

This happens because #getFullName(Object) eventually calls org.eclipse.uml2.uml.NamedElement.getQualifiedName() which by itself returns the name of the Element and its owners - in this case: an instance of the class Model called "UML" (see: http://www.omg.org/spec/UML/20110701).

It is likely that this change has been introduced by the current UML Version.

You may want to switch to the former version of org.eclipse.uml2.uml in order to work around this issue.

FQN construction should be aware of the Naming change for the specific UML version 4.0. It looks like the only way of fixing this is a special handling - I only had a short look at the implementation, though.
Comment 2 Karsten Thoms CLA 2012-09-04 08:07:07 EDT
I just stumbled over this issue when fixing bug#333605. The attached example there had the same issue.
Comment 3 Karsten Thoms CLA 2012-09-04 08:11:55 EDT
Pushed to master
Comment 4 Karsten Thoms CLA 2013-02-07 06:13:29 EST
Part of Kepler M4 (Version 1.3.0)
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:30:38 EDT
Requested via bug 522520.

-M.