Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Duplicated @Override annotation in generated code
Duplicated @Override annotation in generated code [message #1806899] Fri, 17 May 2019 09:23 Go to next message
vincent lorenzo is currently offline vincent lorenzoFriend
Messages: 123
Registered: June 2010
Location: Paris Saclay, France
Senior Member
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 09:24]

Report message to a moderator

Re: Duplicated @Override annotation in generated code [message #1806902 is a reply to message #1806899] Fri, 17 May 2019 10:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6538
Registered: July 2009
Senior Member
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 10:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
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 11:00 Go to previous message
vincent lorenzo is currently offline vincent lorenzoFriend
Messages: 123
Registered: June 2010
Location: Paris Saclay, France
Senior Member
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 11:34]

Report message to a 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: Thu Dec 12 18:33:23 GMT 2019

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

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

Back to the top