Skip to main content



      Home
Home » Modeling » EMF » Duplicated @Override annotation in generated code
Duplicated @Override annotation in generated code [message #1806899] Fri, 17 May 2019 05:23 Go to next message
Eclipse UserFriend
Hello everybody,
working with UML2Ecore from a Papyrus Class Diagram, I get duplicated @Override on the getter and setter of redefined properties in the generated code (I'm redefining properties in my UML model, just to redefine the multiplicity from 0..1 to 1..1 ).

Is it a know bug ? is there a way to avoid this bad behavior ?

In attachement, a small model close to my real one, allowing to reproduce my bug.

I set Duplicated Feature Inheritance, Duplicated Feature and Redefining Properties to Process in my UML genmodel.

index.php/fa/35600/0/

Thank your for your help.

[Updated on: Fri, 17 May 2019 05:24] by Moderator

Re: Duplicated @Override annotation in generated code [message #1806902 is a reply to message #1806899] Fri, 17 May 2019 06:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi

EMF code generation gradually evolves. A recent (since Photon) change is the addition of fuller Java 6 @Overrides annotations. It is possible that the changes to EMF JET templates have not been duplicated in the similar UML JET templates leading to an uncomfortable mix. Please raise an Eclipse UML2 bug.

Workaround, set the GenModel Java compatibility level to Java 5 so that there are no @Overrides at all.

Regards

Ed Willink

Re: Duplicated @Override annotation in generated code [message #1806905 is a reply to message #1806902] Fri, 17 May 2019 06:49 Go to previous messageGo to next message
Eclipse UserFriend
Yes, EMF now generates @Override where they are required for Java 6 compatibility, i.e., for methods that override an interface method. Those are generated only when Java compatibility is set to Java 8 or higher. Of course for Java 5 compatibility EMF continues to generate @Override, but only for methods that override another class' method, so as Ed suggests, changing the compatibility is a temporary workaround.

It is like that UML2's templates generate @Override for methods conditionally for cases where the base EMF templates also generates that in the case of Java 6 compatibility. UML2 will need to change their templates to adjust. It would be good to open a Bugzilla for UML2, along with a simple test case.
Re: Duplicated @Override annotation in generated code [message #1806906 is a reply to message #1806902] Fri, 17 May 2019 07:00 Go to previous message
Eclipse UserFriend
Hi Ed, thank you for your answer. I fill the bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=547424.

I found another workaround to this bug: I add these GenModel EAnnotation to my redefining properties (so the properties of the class Mandatory**Representation in my example).

suppressedGetVisibility -> true
suppressedSetVisibility -> true

It seems me it work find with that.

[Updated on: Fri, 17 May 2019 07:34] by Moderator

Previous Topic:retain order of XML elements when using EMF
Next Topic:How can I add an ECore Modeling Project into my CDO Repository
Goto Forum:
  


Current Time: Sun Jul 13 00:34:20 EDT 2025

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

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

Back to the top