Cyclic definition of overriding

Alex Buckley alex.buckley at
Tue Jun 9 20:36:18 UTC 2015

On 6/9/2015 1:15 PM, Dan Smith wrote:
>> On Jun 9, 2015, at 9:00 AM, Konstantin <konstantin.barzilovich at> wrote:
>> I consider this simple case:
>> interface Test1  {
>>     int foo(); // m1
>> }
>> interface Test2{
>>     int foo(); // m2
>> }
>> class Test implements Test1, Test2{
>> }
>> I try to understand if m1 is inherited by Test. I follow jls-8.4.8-200.
>> All subassertions are true except jls-8.4.8-200-E. To decide if it is true or not we need to turn to overriding definition jls-
> Specifically:
> "There exists no method m' that is a member of the direct superclass or a direct superinterface, D', of C (m distinct from m', D distinct from D'), such that m' from D' overrides the declaration of the method m."
> We've bound our variables as follows:
> C=Test
> D=Test1
> m=m1
> m'=m2
> D'=Test2
> The question we are asking: does m2 override m1 from Test2?
>> More detailed, I want to be sure that m2 isn't m'. That's why I need to know if m2 overrides m1.
>> And new subassertion jls- says about inheriting.
>> " C does not inherit mI."
>> So we get a circle.
> Note the question above: we want to know if m2 overrides m1 from Test2.  Test2 is an interface, so doesn't apply.  Instead, we want
> "An instance method m1, declared in or inherited by an interface I, overrides from I another instance method, m2, declared in interface J, iff both of the following are true:"

Knowing to apply rather than is extremely subtle. Once 
you do, it's plain that does not override-from-Test1 the 
method foo() declared in Test2, and vice versa, thus class Test inherits 
both foo() methods (harmlessly). I will add cross-refs from 8.4.8 to 
both and to clarify.


More information about the compiler-dev mailing list