Bug 435999 - [1.8][pull up] to interface should not make method abstract
Summary: [1.8][pull up] to interface should not make method abstract
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-27 22:24 EDT by John Arthorne CLA
Modified: 2014-08-05 08:12 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2014-05-27 22:24:49 EDT
4.4 RC2

I have a class implementing an interface in the same package. Project EE is set to Java 8. The class contains a trivial public method that does not access any fields. When I do Refactor > Pull Up on the method, attempting to pull method up to interface, the preview shows that the method has been made abstract. However the method body could also be pulled up by creating a default method.
Comment 1 Martin Mathew CLA 2014-05-27 22:42:03 EDT
Currently the method is marked as overriden and the abstract method stub is created in the interface.

Is it better to provide a check-box to chose what user wants as some user might prefer the current implementation?
Comment 2 John Arthorne CLA 2014-05-28 15:56:38 EDT
From a purely user perspective, I could see situations for both behaviours. For example if the method implementation cannot be pulled up due to field references or visibility limits, then pulling up only method signature could be useful (like current behaviour).
Comment 3 Martin Mathew CLA 2014-06-10 04:44:02 EDT
1. Similarly we should allow static and default methods to be pulled up between interfaces.

public interface InterfaceA extends InterfaceB{
	
	public static void staticM2(){
		System.out.println("Something");
	}
}

Invoking pull up on #staticM2 gives error dialog "Members in interfaces cannot be moved".

2. Pull up refactoring from a class to an interface results in compiler error.

public class ClassA implements InterfaceA {
       private static void staticM1() {
		System.out.println("Something");
	}
}
public interface InterfaceA {
]
Invoke pull up refactoring on #staticM1 to InterfaceA, the refactoring results in:
protected abstract static void staticM1();
Also @Override annotation is added to the static method in the class.
Comment 4 Markus Keller CLA 2014-06-11 05:44:03 EDT
(In reply to Manju Mathew from comment #1)
> Is it better to provide a check-box to chose what user wants as some user
> might prefer the current implementation?

Why a checkbox? We already have the "Action" popup / button. In Java 8, the "pull up" action should pull the method up as a default method.