Defaults for Objects' methods

Deepak S Patwardhan deepak.patwardhan at itaas.com
Thu Jul 19 02:20:01 PDT 2012


Hi all,

This has been previously discussed in the thread "defender methods and
method of Object",
http://mail.openjdk.java.net/pipermail/lambda-dev/2012-March/004582.html .

Consider the following (which compiles with lambda build 45)

public interface PrettyPrintable {

    public String prettyString();

    public String toString() default {
        return prettyString();
    }
}

Since the (current) method resolution algorithm will never result in the
invocation of the default body of toString() from this interface, shouldn't
the above give a compilation error with the reason being unreachable code ?
Basically, should we disallow interfaces to provide defaults for Object's
methods ?

Regards,
Deepak S Patwardhan.



More information about the lambda-dev mailing list