Bug 519384

Summary: [override method] Generating code to override method should copy annotations of super method
Product: [Eclipse Project] JDT Reporter: Simeon Andreev <simeon.danailov.andreev>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, loskutov, simeon.danailov.andreev
Version: 4.6   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=353472
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386410
Whiteboard:
Attachments:
Description Flags
Java project with which the problem can be reproduced none

Description Simeon Andreev CLA 2017-07-07 07:49:15 EDT
Created attachment 269280 [details]
Java project with which the problem can be reproduced

It seems this was tracked with bug report 353472, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=353472.

However with 4.6 I don't observe that all annotations are copied from the super method. An example of this is the @Before annotation for junit4, or e.g. @OverridingMethodsMustInvokeSuper.


To reproduce

1. Import project from attached zip.
2. Open type SomeSub.
3. Generated code to override method someMethod.


Observed behavior

The following code is generated:

@Override
public void someMethod() {
    // TODO Auto-generated method stub
    super.someMethod();
}


Desired behavior

Since the super method has the @Before annotation, the generated method should have it as well. So the generated code, in this case, should be as follows:

@Before
@Override
public void someMethod() {
    // TODO Auto-generated method stub
    super.someMethod();
}

I can reproduce this with:

Version: Neon.3+ (4.6.3)
Build id: R20170220-0833
Comment 1 Andrey Loskutov CLA 2017-07-07 08:11:00 EDT
Looks like the fix for bug 353472 was reverted via bug 386410. :-(

Looks like one can't either enable it by default for all, not disable by default for all without make someone angry.

What about to enable this by default for a list of known annotations, which can be extended by user? By default we could have @Before @After etc in the list.