jls overridding description

Dan Smith daniel.smith at oracle.com
Wed May 20 15:50:15 UTC 2015


> On May 20, 2015, at 7:24 AM, konstantin barzilovich <konstantin.barzilovich at oracle.com> wrote:
> 
> Hello,
> 
> Thank you for the answer.
> As I understand, you said that jls-8.4.8.1-100-B can be false while jls-8.4.8.1-100-C is true.

Right: you can have mC with a subsignature of mA, but still inherit mA.

> But is it possible that jls-8.4.8.1-100-C is false while jls-8.4.8.1-100-B is true? (the opposite situation)

Can you not inherit mA, but choose an mC that does not have a subsignature of mA?  Sure.  Note that the selection of mA and mC is pretty unrestricted -- this subsignature clause it what limits the set of methods to things you'd intuitively expect to consider.

So, for example:

public class A {
    public void foo() {} // mA
}

public class B {
    public void bar(int arg) {} // mC
    public void foo() {}
}

Is A a superclass of C?  Yep.  Does C inherit mA?  Nope -- the declaration of another 'foo' method prevents it.  Is mA public?  Yep.

But mC definitely does not override mA.

—Dan


More information about the compiler-dev mailing list