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

Bug 350396

Summary: [extract interface] Extract Interface option to ignore annotations
Product: [Eclipse Project] JDT Reporter: Paul Benedict <pbenedict>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: amj87.iitr, daniel_megert, deepakazad, markus.kell.r, stephan.herrmann
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Paul Benedict CLA 2011-06-27 01:24:59 EDT
Build Identifier: 

"Extract Interface" always pulls the annotations from the source class. I have lots of JPA model classes that I need interfaces for; my annotations end up on the interfaces too after extracting... which is very undesirable for me. I then have to go through all the new interfaces and delete the annotations. Please add a new option to include or exclude annotations from the refactoring.

Reproducible: Always

Steps to Reproduce:
1. Create a class with annotations
2. Extract Interface
3. See the annotations on the new interface
Comment 1 Paul Benedict CLA 2011-06-27 01:26:47 EDT
To clarify, my annotations are on methods.
Comment 2 Ayushman Jain CLA 2011-06-27 01:32:21 EDT
Moving to JDT/UI for follow up.
Comment 3 Paul Benedict CLA 2011-07-25 23:25:26 EDT
I just found out this is also a problem for parameter-level annotations.
Comment 4 Dani Megert CLA 2011-07-26 03:31:57 EDT
Bug 79279 claims that this got fixed but that's not the case.
Comment 5 Paul Benedict CLA 2011-07-26 08:07:18 EDT
Dani, I think Bug 79279 is about not allowing the user to extract a normal interface from an existing @interface? This issue is about an option to choice whether annotations should be copied to the new interface.
Comment 6 Markus Keller CLA 2011-07-26 13:48:32 EDT
Request makes sense and is indeed different from bug 79279. We probably have to add the option to Pull Up and Push Down as well.

The next question is: How often will you actually want to copy the annotations? E.g. an @SuppressWarnings(...) annotation also often refers to the method body:

	@SuppressWarnings("unused")
	@Deprecated
	public void foo(final Object var) {
	}

Maybe we should just never move the annotations.

For method parameters, we already have a similar problem with the 'final' modifier that is useless in the interface. However, certain annotations such as @Nullable might be interesting to keep.

A full-fledged solution could use a user-modifiable list of annotations that should be copied to abstract or interface methods, e.g.

    [ ] Copy annotations to interface methods                 Configure...

... where 'Configure...' is a link to a configuration dialog, similar to how we did it in the Rename Type dialog.
Comment 7 Dani Megert CLA 2011-08-03 02:18:32 EDT
See also bug 353472.
Comment 8 Markus Keller CLA 2012-10-26 07:08:59 EDT
Bug 386410 also fixes this for Extract Interface (i.e. don't copy annotations).

*** This bug has been marked as a duplicate of bug 386410 ***