A Sneak Peek at the Stable Values API
summary
A single-class API (StableValue, JEP 502) exposes safe wrappers around jdk.internal.vm.annotation.@Stable so lambdas run at most once and the VM can constant-fold values, summarized by the slogan codes like lazy initialization, performs like a constant. Live demos build stable suppliers and stable collections (including a stable supplier factory), a Fibonacci stable-list for n=46, and microbenchmarks showing ~0.7 ns/op vs ~6 ns/op for a ConcurrentHashMap cache (~10× faster); records are fast but ordinary instance fields lose trustability.
AI-written summary · about
chapters (12)
- 0:00Introduction to stable values
- 1:24Motivation and JEP 502
- 2:42Live coding: Enterprise app
- 10:12Introducing stable values
- 11:53Stable functions and lists
- 15:08Practical use cases
- 21:35Performance benchmarks
- 22:56Custom stable constructs
- 28:24Advanced trust patterns
- 34:06Refactoring with stable values
- 36:57Summary and conclusion
- 41:14Q&A session
related talks
46mPsst! A Sneak Peek at StableValue and SegmentMapper
57mJava Value Types: what is it and why are they important
45mMinimal Values Under the Hood
20mCache Me If You Can: Speed Up Your JVM with Project Valhalla
35mValhalla Update
51mProject Valhalla: Flat Value Types in Java
52mValhalla - Where Are We?
02h 44mValue Types and Pattern Matching: 1–1, Data at the Center
