Accessing non-final local variables from a lambda expression
forax at univ-mlv.fr
Mon Mar 1 07:15:30 PST 2010
Le 28/02/2010 22:16, Fredrik Öhrström a écrit :
> Peter Levart wrote:
>> With "frame object" I meant an object, allocated on the heap whose class is constructed by
>> compiler and holds all captured local variables (whether final or non-final). I don't know why but
>> this terminology is used by Neal and others.
>> With MethodHandles, local vars can be captured one-by-one via (MethodHandles.insertArgument) but
>> it might still be better to construct a single "frame object" to hold all of them when their
>> number reaches a certain limit or when at least one of them is non-final.
> Be aware that insertArgument might very well be implemented as
> a "closure" using a frame object. See the sample implementation in:
> and the appendArgument implementation at the end of
Peter, latest java.dyn API has a method named MethodHandles.insertArguments
(with a 's' at the end) that allow to insert more than one argument.
More information about the lambda-dev