defender methods and method of Object

David Holmes david.holmes at oracle.com
Sat Mar 3 03:23:49 PST 2012


I don't see any reason to special case Object methods. Superclass wins 
over interface with a default - pure and simple.

David

On 3/03/2012 2:19 AM, Rémi Forax wrote:
> On 03/02/2012 05:08 PM, bitter_fox wrote:
>> Hi,
>> You have to override toString in A to use the default implementation,
>> in this case, using the syntax "Interface.super.method()":
>> (because the definition of super-class is preferred if the extended
>> definitions from super-class and super-interface are clashing)
>>
>> public class A implements Foo
>> {
>>      public String toString()
>>      {
>>          return Foo.super.toString();
>>      }
>> }
>>
>> new A().toString(); // returns "Foo"
>>
>> However, this calling would be StackOverflowError because the syntax
>> may be only on "Syntax" and be not implemented for byte code.
>>
>> I can't judge that semantics is right or wrong, so I only refer to the
>> way to override.(Although I think it is right...)
>> Excuse me if you already know the way.
>
> No problem.
> I just think that the semantics should be changed a little bit by adding
> a special case for method from Object because
> otherwise the default method will be never called directly
> (as you said, you can use I.super.foo()).
>
>>
>> Regards,
>> bitter_fox
>
> cheers,
> Rémi
>
>


More information about the lambda-dev mailing list