Project Amber
Project Amber is the OpenJDK project for smaller, productivity-oriented language features — the ones that change how everyday Java reads rather than how the JVM performs. If code written today looks unlike Java 8, Amber is most of the reason.
What it has delivered, each with its own entry here:
- Records (Java 16) — declare a transparent carrier for data without writing constructors, accessors,
equals,hashCodeandtoString. - Sealed classes (Java 17) — say exactly which classes may implement an interface or extend a class, which is what lets the compiler reason about a hierarchy exhaustively.
- Pattern matching and switch expressions — test a value’s shape and bind its parts in one step, and use
switchas an expression with exhaustiveness checked at compile time. - Text blocks (Java 15) — multi-line string literals, so embedded JSON, SQL and HTML stop being a wall of escapes and concatenation.
- Local variable type inference (
var, Java 10).
These features are more connected than they look. Records, sealed classes and pattern matching are deliberately designed to work together: a sealed interface with record implementations lets a switch over that interface be checked for exhaustiveness, which is how Java expresses an algebraic data type. Amber shipped them separately, over several releases, but they were designed as one idea.
Amber’s later work has continued in the same direction — making the on-ramp to the language gentler for people writing their first program, and reducing the ceremony a small file needs before it does anything.
See Also
Found a mistake, or something to add? Edit this page on GitHub