Inheritance
Rémi Forax
forax at univ-mlv.fr
Fri May 16 07:26:31 PDT 2008
Mark Mahieu a écrit :
> Hi Zdeněk,
>
> I think the problem here is that the types { => Integer }, { => Number
> } and { => Object } are all instances of the same generic interface
> (javax.lang.function.O<R,X>) but with different type arguments, and
> according to the JLS :
>
>
> /"A class may not at the same time be a subtype of two interface types
> which are different invocations of the same generic interface
> /_/(§9.1.2)/_
> <http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#78598>/,
> or an invocation of a generic interface and a raw type naming that
> same generic interface./
>
> /.../
>
> /This requirement was introduced in order to support translation by
> type erasure /_/(§4.6)/_
> <http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#108979>/."/
>
> (From http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.5
> )
>
>
> Regards,
Mark, this argument works for
interface Simple extends { => Integer }, { => Number }, { => Object } { }
but not for:
interface I1 extends { => Integer } { }
interface I2 extends { => Number } { }
interface I3 extends { => Object } { }
interface Simple extends I1, I2, I3 {}
because I1, I2 and I3 are reified types.
Neal, are you sure you want to allow a class or an interface to
implements/extends
a function type ? Have you a real use case for that ?
I think it prevent to use JSR292's MethodHandle to implement function type.
>
> Mark
Rémi
>
>
> On 16 May 2008, at 08:32, tronicek at fel.cvut.cz
> <mailto:tronicek at fel.cvut.cz> wrote:
>
>> Hi,
>>
>> this is compilable:
>>
>> interface J1 {
>> Integer invoke();
>> }
>>
>> interface J2 {
>> Number invoke();
>> }
>>
>> interface J3 {
>> Object invoke();
>> }
>>
>> interface J4 extends J1, J2, J3 { }
>>
>> class C3 implements J1, J2, J3 {
>> public Integer invoke() { return null; }
>> }
>>
>> class C4 implements J4 {
>> public Integer invoke() { return null; }
>> }
>>
>> and this is not:
>>
>> interface I1 extends { => Integer } { }
>>
>> interface I2 extends { => Number } { }
>>
>> interface I3 extends { => Object } { }
>>
>> interface I4 extends I1, I2, I3 { }
>>
>> class C1 implements I1, I2, I3 {
>> public Integer invoke() { return null; }
>> }
>>
>> class C2 implements I4 {
>> public Integer invoke() { return null; }
>> }
>>
>> But probably should be. As well as this:
>>
>> interface Simple extends { => Integer }, { => Number }, { =>
>> Object } { }
>>
>> Zdenek
>> --
>> Zdenek Tronicek
>> Department of Computer Science and Engineering
>> Prague tel: +420 2 2435 7410
>> http://cs.felk.cvut.cz/~tronicek <http://cs.felk.cvut.cz/%7Etronicek>
>>
>>
>>
>>
>>
>>
>
More information about the closures-dev
mailing list