Name of lambda parameters (original) (raw)

Brian Goetz brian.goetz at oracle.com
Mon Jan 7 10:16:24 PST 2013


I think this goes into the general bucket of "you can't do reflection below the method level in Java", and lambda expressions are expressions and therefore below the method level. Is lambda somehow special here?

On 1/7/2013 1:04 PM, Remi Forax wrote:

(CC Alex Buckley)

As noticed recently on lambda-dev mailing list, there is no way to get the parameter names of a lambda because there is no way to do reflection on a lambda (an object implementing a functional interface) to get the corresponding declared method. do we need a static method Parameter[] Method.getLambdaParameters(Object lambdaProxy) ? The fact that it takes an object and not stable value (like a class, etc) doesn't seem a good idea This may require bookkeeping when doing the functional interface conversion. By example, the generated lambda proxy can implement a non-public interface to extract this information and for the method handle proxy, it can use the internal API used by the metafactory to crack the method handle. So, like serialization, may we need to have a special empty interface NamedParameterLambda to tag these specific lambdas ? In that case, the method getLambdaParameters can be a static method of NamedParameterLambda, Parameter[] getLambdaParameters(NamedParameterLambda lambdaProxy). Rémi



More information about the lambda-libs-spec-observers mailing list