From virtual extension methods to mixins

Rémi Forax forax at univ-mlv.fr
Tue Jul 10 01:42:50 PDT 2012


On 07/10/2012 09:06 AM, James Shaw wrote:
> On 10 July 2012 02:02, Brian Goetz <brian.goetz at oracle.com> wrote:
>
>> Yes, this is what I call the "virtual field pattern."  It seems perfectly
>> reasonable to me, because the classes that mix you in have to consent by
>> providing the {get,set}Peeker methods.  (Also, by the nature of interface
>> method merging, it addresses the diamond problem as if all base classes
>> were "virtual".)
>>
>>
>>
> Can you explain what you mean by 'diamond problem'?
>

It's a classical problem of multiple inheritance,
let suppose we have:

class A {
   int a;
}
class B extends A {}
class C extends A {}
class D extends B, C {}

The question is how many 'a' you have in D, using an abstract getter in A
solves the problem because in that case you have only one field in D.

cheers,
Rémi



More information about the lambda-dev mailing list