4 ms·
My impression from the openjdk code is that each lambda generates: 1. A method in its parent class. 2. An invokedynamic instruction at the call site. The inv
by georgewfraser 12y ago
My impression from the openjdk code is that each lambda generates:
1. A method in its parent class.
2. An invokedynamic instruction at the call site.
The invokedynamic instruction calls LambdaMetafactory, which compiles an anonymous class at runtime that calls method #1. So the only benefit of using invokedynamic is fewer class files, by deferring generating them until runtime.
- pron 12y agoNon-capturing lambdas also don't instantiate a new object at each call site. But this is also doable without invokedynamic.