Formal model for defender method resolution

Neal Gafter neal at gafter.com
Fri Jan 28 12:30:42 PST 2011


On Fri, Jan 28, 2011 at 11:38 AM, Brian Goetz <brian.goetz at oracle.com>wrote:

> Some people find this "sub-inheritance" (inheritance of part of a
> signature) disturbing, because there is no precedent for it in Java.
>
> What do people think?  Do you find this interpretation of B (m()
> continues to use A's default) confusing or natural (or both)?
>

I find it confusing that you consider the default to be part of the
signature.

Your proposal here (B.m inherits A's default) feels ok to me, but I could
see it going the other way.  Here's why.

In the more general case with covariant overriding

interface A {
    A f() { ... }
}
interface B extends A {
    B f();
}

I don't think there needs to be any error on B.  At compile-time, any class
that implements B will have to provide an implementation for B.f() [it is
after all abstract], so the error on B serves little purpose.  At runtime,
A.f and B.f have distinct VM signatures and are therefore unrelated
methods.  (Is it intentional that your formalism doesn't reflect that?)
Handling the non-covariant case the same as the covariant case (the method
becomes abstract) would therefore be a natural solution.


More information about the lambda-dev mailing list