Community
Participate
Working Groups
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
To clarify, my annotations are on methods.
Moving to JDT/UI for follow up.
I just found out this is also a problem for parameter-level annotations.
Bug 79279 claims that this got fixed but that's not the case.
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.
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.
See also bug 353472.
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 ***