Lambdas in Java: A Peek Under the Hood
summary
Explains how Java SE 8 implements lambdas by emitting a recipe (not inner classes) and using JVM features introduced in Java 7: invokedynamic plus method handles and a runtime lambda metafactory. Compiler desugars lambda bodies to methods, bootstrap links each call site once, and non‑capturing lambdas are cached so hotspots see up to ~70× throughput gains under saturation while capturing lambdas match anonymous‑class cost; serialization records the recipe so deserialization rebuilds lambdas across JVM versions.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 2:24Lambda expressions for Java
- 4:02Why lambdas for Java?
- 5:44Big question #1: typing
- 9:10Functional interfaces
- 12:05Big question #2: representation
- 16:02New bytecode tool: Method Handle
- 19:15Stepping back...
- 20:49Bytecode invocation modes
- 21:38New bytecode tool:invokedynamic
- 30:34Translation strategies
- 31:40Indy: the ultimate procrastination aid
- 32:40Indy: the ultimate lazy initialization
- 34:08Indy: the ultimate indirection aid
- 34:59Performance costs
- 36:16Performance example - linkage cost
- 37:32Performance example - capture cost
- 40:47Future VM support (?)
- 42:49Serialization
- 44:54Summary
related talks
39mImplementing Lambda Expressions in Java
44mIt’s Java, but Not As We Know It
45mWhat Java Compiles To
06mOffers a View Into Lambda Development
41mThe... wonderful? World of lambdas
18mThe Hidden Dynamic Life of Java
44mScala 2.12 & Java 8: More Fun Together!
01h 07mJava SE: Lambdas, Streams & Future Directions
