Bug 547424 - Duplicated @Override annotation in generate code
Summary: Duplicated @Override annotation in generate code
Status: VERIFIED FIXED
Alias: None
Product: MDT.UML2
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 5.5.2   Edit
Assignee: Christian Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 547425
  Show dependency tree
 
Reported: 2019-05-17 06:53 EDT by Vincent Lorenzo CLA
Modified: 2021-01-10 11:46 EST (History)
2 users (show)

See Also:


Attachments
a model to reproduce the bug. (57.33 KB, application/octet-stream)
2019-05-17 06:54 EDT, Vincent Lorenzo CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Lorenzo CLA 2019-05-17 06:53:33 EDT
Initial help required was done on the forum thread https://www.eclipse.org/forums/index.php/t/1098961/

I generate EMF code from a UML (Papyru) model, where I use property's redefinition. The generated java code contains duplicated @Override (and so, it doesn't compile). 
In attachment, a model to reproduce the bug.
Comment 1 Vincent Lorenzo CLA 2019-05-17 06:54:36 EDT
Created attachment 278638 [details]
a model to reproduce the bug.
Comment 2 Christian Damus CLA 2020-12-11 08:49:58 EST
I'm seeing the same problem in generation of overrides for getters in a subclass that add subsets to an inherited superset feature. And I have a fix to contribute.

The problem is that annotation-insertion templates for getters and setters reuse the corresponding templates for basic-setters and basic-getters, which I suppose the Ecore templates don't generate overrides for in the same way. This reuse of those templates doesn't account for the fact that the base Ecore template already generates an @Override in the getter and setter, so that we end up with two in the generated output.
Comment 3 Eclipse Genie CLA 2020-12-11 09:01:54 EST
New Gerrit change created: https://git.eclipse.org/r/c/uml2/org.eclipse.uml2/+/173700
Comment 4 Ed Willink CLA 2020-12-11 14:39:40 EST
I think this is the inevitable consequence when a project decides to 'improve' the EMF JET templates which have limited override capability. Too much requires copy and paste and so goes stale when EMF improves.

It is also a problem that EMF has not had a coherent advance-beyond-Java-5 session. Rather I have identified a variety of problems that occur with Java > 5 and Ed has fixed some of them.

Unfortunately this means that UML must re-copy the changes to avoid inconsistencies, particularly where UML has a different fix. And since it is a pain for committers to remember to review EMF changes, there need to be JUnit tests that animate as much of the user experience as possible.

(OCL and QVTd have such tests for genmodel and for code generation and ongoing execution that run weekdays after a master commit, and on Sundays regardless.)

(For OCL I try to have a commit that represents the unadulterated clone source so that it is easier to apply EMF changes to the clone.)
Comment 6 Eclipse Genie CLA 2020-12-14 13:08:22 EST
New Gerrit change created: https://git.eclipse.org/r/c/uml2/org.eclipse.uml2/+/173758
Comment 8 Kenn Hussey CLA 2020-12-14 19:57:07 EST
The fix has been commited to both the 'master' and 'R5_5_maintenance' branches and will be shipped in the next UML2 release (nominally 5.5.2).
Comment 9 Kenn Hussey CLA 2021-01-10 10:43:38 EST
The fix is now available in a milestone build towards 5.5.2.
Comment 10 Christian Damus CLA 2021-01-10 11:46:48 EST
Milestone build confirmed by installation via Papyrus Oomph profile. Thanks!