A new feature coming in JDK 8 allows you to add to an existing interface while preserving binary compatibility.
The syntax is like
public interface S
There are two scenarios:
1) First, that was mentioned, where there is no most specific interface
public interface A {
default void doStuff(){ /* implementation */ }
}
public interface B {
default void doStuff() { /* implementation */ }
}
public class C implements A, B {
// option 1: own implementation
// OR
// option 2: use new syntax to call specific interface or face compilation error
void doStuff(){
B.super.doStuff();
}
}
2) Second, when there IS a more specific interface:
public interface A {
default void doStuff() { /* implementation */ }
}
public interface B extends A {
default void doStuff() { /* implementation */ }
}
public class C implements A, B {
// will use method from B, as it is "closer" to C
}