Lambda translation (original) (raw)
Rémi Forax forax at univ-mlv.fr
Sun Apr 22 13:40:44 PDT 2012
- Previous message: Lambda translation
- Next message: Lambda translation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 04/22/2012 07:09 PM, Brian Goetz wrote:
I've posted a document about how we translation lambdas to bytecodes, and what the VM/language runtime does with those bytecodes at run time, here:
http://cr.openjdk.java.net/~briangoetz/lambda/lambda-translation.html The putbacks that have been going in recently that talk about "metafactories" implement the approach described in this document.
In section "Static vs instance methods", 'REF_invokeSpecial' should be 'REF_invokeVirtual'.
In section "varargs", there is no need for a bridge because if the strategy is "inner classes", the bridge code can be inserted in the generated method of the proxy and if the strategy uses method handle you can use regular combiners.
For serialization/accessibility, I think it's better to have a new access modifier (let say ACC_LAMBDA) and a new kind of Lookup mode (lambda mode) that allows to bypass normal accessibility if the ACC_LAMBDA is set.
So for the lambda byLength, the generated code will be
| private static /accclambda/ int lambda$1(String a, String b) { return a.length() - b.length(); }|
and the readResolve can should just do
lambdaLookup().findStatic(lambda.getSamClass(), lambda.getSamMethodName(), etc.)
For method reference, it's more complex because the compiler can't add the ACC_LAMBDA after the fact, perhaps only public method of public class can be serialized.
Rémi
- Previous message: Lambda translation
- Next message: Lambda translation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]