Brian Goetz mailed the Project Lambda ("closures for jdk 7") mailing
list with a proposal for "virtual extension methods" AKA "defender
methods".

http://mail.openjdk.java.net/pipermail/lambda-dev/2010-May/001304.html

PDF with current strawman proposal is
http://cr.openjdk.java.net/~darcy/DefenderMethods.pdf

"Existing interfaces could be added to without compromising backward
compatibility by adding extension methods to the interface, whose
declaration would contain instructions for finding the default
implementation in the event that implementers do not provide one."

The idea is roughly that using this, new methods could be added to a
Java interface and could refer to an implementation method in another
class. Any class which implemented version 1 of the interface would
pick up the new method signature from version 2, but if the class
hadn't implemented the new method yet, it would transparently delegate
to the implementation method declared in the interface.

The PDF is pretty clear and easy to follow, worth a read.

The best thing about the proposal IMO is the naming: "You could call
these “public defender” methods (or defender methods for short) since
they are akin to the Miranda warning: “if you cannot afford an
implementation of this method, one will be provided for you.”


Patrick

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to