I.super.f() usage in Java 8
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Sep 12 15:31:22 UTC 2014
Hi Boaz,
as I wrote in a comment in the bug - javac's logic is more precise than
the one described in the spec. This means that javac only issues errors
when there is what we call 'level-skipping' i.e. when you try to access
a method from your super's super through a qualified super call. The
spec disallows this with a looser check, which ends up rejecting more
stuff than just that that leads to level skipping. Is there any reason
as to why the spec check has been defined in this particular way?
Maurizio
On 12/09/14 16:26, Boaz Nahum wrote:
>
> So class J, even not override 'f' hide what was before a public method.
>
> So to get around I need to (suppose T is mine)
>
> interface Was_I extends I {
>
> default int was_f() { return I.super.f(); }
>
> }
>
> class J implements I { }
> class T extends J implements Was_I {
> public int f() {
> return Was_I.super.was_f();
> }
> }
>
> I understand that if J implements f than this rule make sense.
>
> Not sure I like this bug to be fixed :(
>
> R.
>
> Boaz
>
> On Sep 11, 2014 8:22 PM, "Maurizio Cimadamore"
> <maurizio.cimadamore at oracle.com
> <mailto:maurizio.cimadamore at oracle.com>> wrote:
>
> Hi John,
> yes - this appears to be a bug; I filed this as:
>
> https://bugs.openjdk.java.net/browse/JDK-8058244
>
> Thanks
> Maurizio
>
>
> On 11/09/14 16:53, John Spicer wrote:
>
> Java 8 supports a new user of super:
>
> interface I {
> default int f(){return 0;}
> }
>
> class X implements I {
> public int f() {
> return I.super.f();
> }
> }
>
> This is described in 15.12.1.
>
> However, there is wording in 15.12.1 that says: Let T be the
> type declaration immediately enclosing the method invocation.
> It is a compile-time error if Iis not a direct superinterface
> of T, or if there exists some other direct superclass or
> direct superinterface of T, J, such that J is a subtype of I.
>
> That would seem to require an error on this case, because T
> has a superclass of J, which is a subtype of I.
>
> interface I {
> default int f(){return 0;}
> }
> class J implements I { }
> class T extends J implements I {
> public int f() {
> return I.super.f();
> }
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20140912/c2512aac/attachment.html>
More information about the compiler-dev
mailing list