So basically you kids that think this is a bad idea subscribe to the: “All public interfaces, once released, shall have a fixed set of methods forever and ever, AMEN!” notion? This seems to me to add way more complexity than a trivial default method decl.
Since I’m lazy, I just grabbed a trival example from someone’s blog and sliced-and-diced it:
Today’s reversing some instance of the List interface with the Collections helper class.
List list;
//...
Collections.reverse(list);
The massively complex addition needed for integrating ‘reverse’ into List:
public interface List extends Collection
{
// all the current method defs in List
...
// Yikes, this is mind numbing!
extension void reverse() default Collections.reverse;
}
With this addition, every class in the whole-wide-world which implements “List” still auto-magically works. Yea! Now we can instead write:
List list;
//...
list.reverse();
Which, if you’re being honest, you’ll have to admit is much cleaner looking than calling a static method in a utility class. But that’s simply an added bonus. The routines in Collections know nothing about the implementation details of the given concrete class. Therefore they have to “perform the operation in the stupidest way possible ™”. But now any class which implements List can override the reverse method and it just auto-magically works ™. Progress!
So now, joe-average/student programmer don’t even need to know about the existence of the “Collections” helper class. All they need to know is that List has a ‘reverse’ method and the rest is merely an implementation detail.
For non-joe-average programmer, life is better as well. The only way to work around this issue is a huge mess of ‘instanceof’ nonsense. How is that less complex? And compared to convariant overrides, this should be a walk in the park.
All of the above is again trivial. Interesting usages remain to be seen and depend on the final spec and how it interops with lambdas.