Syntax for calling “super” in Java 8 Defender methods

This is a very interesting discussion. How to reference default methods from implemented interfaces throughout the class / interface hierarchy?

Situation:

interface K {
  int m() default { return 88; }
}

interface J extends K {
  int m() default { return K.super.m(); }
                        // ^^^^^^^^^^^^ How to express this?
}

Solution ideas:

  • K.super.m()
  • super.K.m()
  • ((K) super).m()
  • K::m()
  • K.default.m()
  • super<K>.m()
  • super(K).m()
  • super(K.class).m()
  • super[K].m()

Any other crazy ideas? See the discussion here:

http://mail.openjdk.java.net/pipermail/lambda-dev/2012-August/005616.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s