No matter the size of your company, Azul offers competitive pricing options to fit your needs, your budget, and your ambition.
No matter the size of your company, Azul offers competitive pricing options to fit your needs, your budget, and your ambition.
Java 21 is the fourth long-term support release under the six-month release cadence. It followed Java 20 and preceded Java 22. Java 25 (September 2025) is the current LTS release, though Java 21 remains in active support through December 2029.
| Release Date | September 19, 2023 |
| LTS | Yes |
| OpenJDK End-of-Life | December 2029 |
| Minimum Supported Versions | Azul Zulu: 11, 17, 21, 25 |
Record Patterns (JEP 440)
Record patterns destructure record components directly in instanceof and switch expressions. Combined with sealed classes (JEP 409, Java 17), this enables exhaustive pattern matching over algebraic data types.
static String format(Shape shape) {
return switch (shape) {
case Circle(var r) -> “circle: radius=” + r;
case Rectangle(var w, var h) -> “rect: ” + w + “x” + h;
case Triangle(var b, var h) -> “triangle: base=” + b + ” height=” + h;
};
}
Pattern Matching for switch (JEP 441)
Finalizes the feature previewed in Java 17 (JEP 406) and Java 18-20. Switch expressions and statements now support type patterns with instanceof semantics, guarded patterns with when clauses, and exhaustive checking against sealed hierarchies.
static String classify(Object obj) {
return switch (obj) {
case Integer i when i > 0 -> “positive integer”;
case Integer i -> “non-positive integer”;
case String s -> “string of length ” + s.length();
case null -> “null”;
default -> “something else”;
};
}
Virtual Threads (JEP 444)
Virtual threads are lightweight threads managed by the JVM, not the OS. Millions of virtual threads can run concurrently on a bounded platform thread pool. This makes thread-per-request architectures viable at scale without reactive programming models or async callbacks.
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
IntStream.range(0, 10_000).forEach(i -> executor.submit(() -> {
Thread.sleep(Duration.ofSeconds(1));
return i;
}));
}
Virtual threads are suited to I/O-bound workloads (HTTP calls, database queries, file reads). CPU-bound workloads see no benefit over platform threads.
Structured Concurrency (Preview, JEP 453)
An API for treating multiple concurrent tasks as a single unit of work. A structured task scope ensures all subtasks complete or fail together, eliminating resource leaks from orphaned threads. Previewed in Java 21, incubated in earlier releases.
Scoped Values (Preview, JEP 446)
An alternative to ThreadLocal for immutable data shared across virtual threads. Scoped values are bound for a bounded lifetime and cannot be mutated after creation, avoiding the memory leak and inheritance pitfalls of ThreadLocal.
Sequenced Collections (JEP 431)
New interfaces SequencedCollection, SequencedSet, and SequencedMap provide consistent APIs for accessing first and last elements, and iterating in reverse order. List, SortedSet, SortedMap, and LinkedHashSet now extend these interfaces.
Key Encapsulation Mechanism API (JEP 452)
An API for key encapsulation mechanisms (KEMs), used in hybrid public-key encryption. Supports KEM algorithms via the existing cryptographic service provider framework.
Generational ZGC (JEP 439)
ZGC now operates in generational mode by default, separating young and old generations for improved allocation throughput. Non-generational mode was removed in Java 24 (JEP 490).
Foreign Function and Memory API (Preview, JEP 442)
Third preview of the API for calling native code and managing off-heap memory without JNI. Finalized in Java 22 (JEP 454).
Preview Features
| JEP | Feature | Status |
|---|---|---|
| JEP 430 | String Templates | Withdrawn after multiple previews |
| JEP 443 | Unnamed Patterns and Variables | Finalized in Java 22 (JEP 456) |
| JEP 445 | Unnamed Classes and Instance Main Methods | Finalized in Java 25 (JEP 512) |
Java 21 is the recommended upgrade for organizations on Java 17 LTS. Migration considerations:
Azul Platform Core provides TCK-certified builds of OpenJDK 21 with extended support beyond the OpenJDK end-of-life date. Features include:
Contact us to learn more about our migration services, support, modernization services, and more!