If I'm not mistaken, in certain situations lambda in Java is generated as an instance of an anonymous class. For example, in this lambda code, you need to capture a variable from the outside:
final int local = 123456; list.forEach(x -> System.out.println(x + local));
Does this mean that the garbage collector will require lambda as an object?
No, it will not; this is not how lambdas work.
Yes, an instance of the class is generated; no, he will not disappear.
- , invokedynamic; , , JIT , , . , " " .
invokedynamic
- , , JIT {static, virtual, interface, special} , . , JIT, .
, , -, , , . , , , , -, .
, , -. factory invokedynamic call. factory , . factory , , .
, - , bootstrap , . , .
, invokedynamic -, : http://mydailyjava.blogspot.no/2015/03/dismantling-invokedynamic.html?m=1
HotSpot, .