Formal model for defender method resolution

Stephen Colebourne scolebourne at joda.org
Tue Feb 1 01:58:51 PST 2011


On 1 February 2011 08:05, Peter Levart <peter.levart at marand.si> wrote:
> So what we have here is two distinct desirable semantics for an interface method that overrides a method in a superinterface:
>
> a) re-abstraction (that discards any default definition in a supertype)
> b) re-declaration (that inherits any default definition from a supertype)
>
> These two semantics can both be supported, followed by two distinct syntaxes:
>
> interface A {
>  Object m() default Defaults.m;
> }
>
> interface B  extends A {
>  Object m(); // re-abstraction
> }

While a rare case, I do think the re-abstraction case is worth
supporting if at all possible.

> interface C extends A {
>  Object m() default; // re-declaration which inherits default from A
> }

Or be more explicit - use a reference to a super-interface as the
default. Its eminently readable and understandable:

interface C extends A {
 Object m() default A.m();
}

Stephen


More information about the lambda-dev mailing list