Site icon Java, SQL and jOOQ.

Java 8 virtual extension methods

I’ve been following the evolution of the Java 8 Lambda expressions project for a while now, and I’m really thrilled by its current state of progress. The latest “easy-to-understand” presentation I’ve found is this one: http://blogs.oracle.com/briangoetz/resource/devoxx-lang-lib-vm-co-evol.pdf Now, as an API designer, I’m particularly interested in the concept of virtual extension methods and I was wondering whether it was also considered to introduce “final” extension methods as opposed to “default” ones. For example:

interface A {
  void a();
  void b() default { System.out.println("b"); };
  void c() final { System.out.println("c"); };
}

When implementing the above interface A, one… Advantages: Disadvantages: As with multiple inheritance itself, careful API designers could further improve their API’s when using final extension methods, whereas less careful API designers might break client code. But this is the case with previous usage of “final” as well, so I think final extension methods would be a very nice addition to Java 8. See the full mail and follow-up on the lambda-dev mailing list here: http://mail.openjdk.java.net/pipermail/lambda-dev/2011-December/004426.html
Exit mobile version