jeudi 21 janvier 2016

Java 8: convert lambda to a Method instance with clousure included

(This is difficult to search because results are all about "method reference")

I want to get a Method instance for a lambda expression for use with a legacy reflection-based API. The clousure should be included, so calling thatMethod.invoke(null, ...) should have the same effect as calling the lambda.

I have looked at MethodHandles.Lookup, but it only seems to be relevant for the reverse transform. But I guess the bind method may help to include the clousure?





Aucun commentaire:

Enregistrer un commentaire