I've this java source file:
import java.util.function.*;
public class t {
public static void main(String[] args) {
Function<Integer,Integer> r = (a) -> a*a+2*a+1;
System.out.println(r.apply(2));
}
}
I compile it and it works as expected. Here's the output of javap -c -v t
, and I can't find the location of lambda in it. Where's the bytecode which tells the jvm to compute the expression with the input Integer
whenever the lambda is envoked?
If you want to see the code of your lambda body
a*a+2*a+1
, you should calljavap -c -v -p t
to see also the private methods:More detailed answer about the lambda inner implementation is here: How will Java lambda functions be compiled?