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