Community
Participate
Working Groups
The "Pull up" refactoring, when used to pull up to an interface, has all sorts of quirks. Here's a few, illustrated by an example (more quirks at the bottom). Start with this class and pull up the "baz" method. Accept the warning to make the method more visible: public class PullUpToInterfaceBug { interface Foo { } static class Bar implements Foo { /** baz it! */ void baz(final String s) { } } } ****************** You end up with this ****************** public class PullUpToInterfaceBug { interface Foo { protected abstract void baz(final String s); } static class Bar implements Foo { /** baz it! */ @Override protected void baz(final String s) { } } } ***************** 1. the method added to the interface is declared "protected" and "abstract", and the param is "final", none of which are appropriate for interfaces (it should read be "void baz(String s)") 2. the javadoc was not moved (or even copied) to the interface 3. the visibility of the implemented method went to "protected", which is invalid. It should be "public" 4. Furthermore, if doing the same to this class: ***************** import java.util.List; public class PullUpBaz implements PullUpToInterfaceBug.Foo { public void b() { List<Object> l = null; } } ***************** causes PullUpToInterfaceBug to have an import of java.util.List, even though List is not used in the signature (only in the method body).
(In reply to "Z" Zorzella from comment #0) > > 1. the method added to the interface is declared "protected" and "abstract", > and the param is "final", none of which are appropriate for interfaces (it > should read be "void baz(String s)") > > 3. the visibility of the implemented method went to "protected", which is > invalid. It should be "public" These 2 will be handled in bug 428965. > 2. the javadoc was not moved (or even copied) to the interface This will be handled in bug 326832. > 4. Furthermore, if doing the same to this class: > causes PullUpToInterfaceBug to have an import of java.util.List Updated this bug's title to reflect this issue.
*** Bug 467490 has been marked as a duplicate of this bug. ***
*** This bug has been marked as a duplicate of bug 497368 ***