defender methods and method of Object

Rémi Forax forax at univ-mlv.fr
Fri Mar 2 06:50:05 PST 2012


Hi all,
With the current semantics, there is no way to override a method of
java.lang.Object with a default method.
By example,

interface Foo {
   public String toString() { return "Foo"; }
}
public class A implements Foo {
}
...
A a = new A();
a.toString() -> calls Object::toString()

I think it's not the right semantics because you can all on an interface
all the method of java.lang.Object so an interface is a type more specific
than Object.

Rémi



More information about the lambda-dev mailing list