lambda and MethodHandles in current prototype
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Nov 21 02:46:05 PST 2011
On 20/11/11 19:58, Peter Levart wrote:
> Has the compilation strategy changed? Aren't MethodHandles used any more or are they still, but the conversion to functional interfaces doesn't use MethodHandleProxies.asInterfaceInstance()? Are there any plans for the above code to print true/true (or at least false/true)?
Yes, the implementation has changed - the compiler used
MethodHandleProxies.asInterfaceInstance for translating method
references - a couple of weeks ago I cleaned up the compiler to support
two different (and consistent) translation strategies:
*) by default, the compiler will generate anonymous inner class for
lambdas/method references
*) optionally (if you use the -XDlambdaToMethod flag), the compiler will
use 292, by passing method handles on to a fake BSM lambda metafactory
that will spin the bytecode on the fly.
So, the conclusion is that the compiler doesn't use
MethodHandleProxies.asInterfaceInstance directly anymore - either it
just emit an anonymous inner class, or it defers creation to a BSM which
then could, in principle, use MethodHandleProxies.asInterfaceInstance or
do some other fancy stuff to spin bytecode on the fly.
Maurizio
More information about the lambda-dev
mailing list