Implementing Lambda Expressions in Java
summary
Java implements lambdas by emitting an invokedynamic call (JSR 292) that defers creation to a runtime lambda metafactory which returns instances of existing functional interface types; the compiler synthesizes a private method for the lambda body and passes captured values as dynamic args. Implementations can generate classes at link time, reuse one wrapper per interface, or return a cached constant for stateless lambdas. Measured results show worst-case parity with inner classes and best-case 4–20× faster; serialization uses a SerializedLambda descriptor and reconstitution by the capturing class to avoid new security holes.
AI-written summary · about
chapters (17)
- 0:00Intro
- 0:15Adding lambda expressions to Java
- 4:37Functional interfaces
- 7:01We could "just" user inner classes
- 8:29Stepping back...
- 9:43Its not just for dynamic languages anymore
- 12:03Desugaring lambdas to methods
- 13:52Lambda capture
- 15:10The metafactory API
- 17:09Candidate translation strategies
- 19:41Indy: the ultimate lazy initialization
- 21:31Indy: the ultimate procrastination aid
- 24:49Performance example - capture cost
- 28:13Not just for the Java Language!
- 29:23Possible VM support
- 31:10Serialization
- 36:03My VM wish-list








