Inheritance
Mark Mahieu
mark at twistedbanana.demon.co.uk
Fri May 16 04:09:51 PDT 2008
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), 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)."
(From http://java.sun.com/docs/books/jls/third_edition/html/
classes.html#8.1.5 )
Regards,
Mark
On 16 May 2008, at 08:32, 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
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080516/214613f9/attachment.html
More information about the closures-dev
mailing list