TL;DR: Java 26 brings GC-independent AOT caching that works with ZGC, HTTP/3 support in HttpClient, a simplified Lazy Constants API replacing Stable Values, and warns against reflective final field mutation — all while cleaning up legacy code by removing the Applet API and Thread.stop().
Java 26 was released on March 17, 2026 as part of Java’s six-month release cycle. With 10 JEPs delivered, it’s a focused release — half are new features or improvements (HTTP/3, AOT with any GC, G1 throughput boost), while the other half continue preview/incubator work on Lazy Constants, Structured Concurrency, Primitive Patterns, PEM Encodings, and Vector API. The release also removes two pieces of legacy code: the Applet API and Thread.stop().
JEP 500: Prepare to Make Final Mean Final
Java has always promised that final fields are immutable — once set, they can’t change. But there’s been a loophole: Deep Reflection (introduced in Java 24) can bypass that guarantee and mutate final fields through reflection. This means code like this was silently possible:
public class Box { private final Object value;
public Box(Object value) { this.value = value; }
@Override public String toString() { return "Box{value=" + value + "}"; }}// Somewhere else — even from a third-party library...Box box = new Box("hello");System.out.println(box); // Box{value=hello}
Field field = Box.class.getDeclaredField("value");field.setAccessible(true);field.set(box, "goodbye"); // Works! Breaks the "final" contract.
System.out.println(box); // Box{value=goodbye} ← unexpected mutationJava 26 starts closing that loophole with warnings and enforcement options via --illegal-final-field-mutation:
| Mode | Behavior |
|---|---|
allow | No warning or error (default before Java 26) |
warn | Prints a warning when final fields are mutated reflectively (Java 26 default) |
debug | Prints a stack trace on every mutation for debugging |
deny | Throws IllegalAccessException — the mutation is blocked |
# Run with warnings (default in Java 26)java --illegal-final-field-mutation=warn MyApp
# Block mutations entirely (future default behavior)java --illegal-final-field-mutation=deny MyAppThe future: In a later release, the default will flip to deny. If you need reflective final field mutation (rare), you’ll have to opt in with --enable-final-field-mutation=<module>. The JVM can then safely assume final means truly immutable — enabling optimizations like Constant Folding, where the compiler replaces field reads with their known compile-time values, improving performance.
JEP 517: HTTP/3 for the HTTP Client API
The Java HttpClient (since Java 11) now supports HTTP/3 — the latest version of the HTTP protocol, which uses QUIC instead of TCP and offers faster connection setup, better multiplexing, and resilience to packet loss.
HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://example.com")) .version(HttpClient.Version.HTTP_3) // Try HTTP/3, fallback to HTTP/2 .build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, BodyHandlers.ofString());The default is still HTTP_2 — roughly a third of sites support HTTP/3 as of Java 26’s release. Setting the version to HTTP_3 will attempt HTTP/3 and fall back gracefully if the server doesn’t support it. No extra libraries, no configuration hassle.
JEP 516: Ahead-of-Time Object Caching with Any GC
Java 24 introduced AOT class loading — pre-compiling classes into a native cache that can speed up startup by up to 42%. But there was a catch: the cache format was GC-specific. A G1-compiled cache wouldn’t work with ZGC, and vice versa. If you switched garbage collectors (or even tuned certain JVM flags), your carefully built cache became useless.
Java 26 solves this with Streamable Objects — a GC-independent serialization format for cached objects:
| Approach | Speed | Compatibility |
|---|---|---|
| Mapping (existing) | Fastest at startup | Tied to specific GC and flags |
| Streaming (new) | Slightly slower at startup | Works with any GC |
Streamable Objects are used automatically when:
- ZGC is the garbage collector
- Compressed Oops is disabled (
-XX:-UseCompressedOops) - The heap exceeds 32GB
- You set
-XX:+AOTStreamableObjectsexplicitly
This means you can now build an AOT cache once and use it across different GC configurations — a major win for teams that switch between G1 in production and ZGC for low-latency testing.
JEP 522: G1 GC — Improve Throughput by Reducing Synchronization
The G1 garbage collector uses a Card Table to track which heap regions reference objects in other regions. Every time you write an object reference, the JVM updates this table via a write barrier — and a separate optimization thread keeps the table clean. Both operations required synchronization, creating contention under high load.
Java 26 introduces dual Card Tables:
- App threads write to one card table
- The optimizer works on the other
- They swap periodically when one becomes too dirty
No code changes needed — this is a pure JVM improvement. The result: 5–15% throughput increase for G1, with only about 0.2% more native memory as cost. If you’re using G1 (the default), you get this benefit automatically in Java 26.
Preview and Incubator Features
The following five features continue their preview or incubation journey. They require --enable-preview at compile and runtime, except the Vector API which requires --add-modules jdk.incubator.vector.
JEP 524: PEM Encodings of Cryptographic Objects (Second Preview)
PEM — Privacy-Enhanced Mail — is the standard encoding format for certificates, keys, and other cryptographic objects. Before Java 25, reading a PEM-encoded private key required 10+ lines of manual Base64 decoding, cipher initialization, and key specification plumbing:
String encryptedPrivateKeyPemEncoded = ...;String passphrase = ...;
// Strip PEM headers/footers and newlinesString base64Text = encryptedPrivateKeyPemEncoded .replace("-----BEGIN ENCRYPTED PRIVATE KEY-----", "") .replace("-----END ENCRYPTED PRIVATE KEY-----", "") .replaceAll("[\\r\\n]", "");
Base64.Decoder decoder = Base64.getDecoder();byte[] bytes = decoder.decode(base64Text);EncryptedPrivateKeyInfo info = new EncryptedPrivateKeyInfo(bytes);
String algorithmName = info.getAlgName();SecretKeyFactory skf = SecretKeyFactory.getInstance(algorithmName);PBEKeySpec spec = new PBEKeySpec(passphrase.toCharArray());Key pbeKey = skf.generateSecret(spec);
Cipher cipher = Cipher.getInstance(algorithmName);AlgorithmParameters params = info.getAlgParameters();cipher.init(Cipher.DECRYPT_MODE, pbeKey, params);
KeyFactory rsaFactory = KeyFactory.getInstance("RSA");KeySpec keySpec = info.getKeySpec(cipher);PrivateKey privateKey = rsaFactory.generatePrivate(keySpec);Java 25 introduced PEMDecoder, collapsing that into a fluent one-liner:
PrivateKey privateKey = PEMDecoder.of() .withDecryption(passphrase.toCharArray()) .decode(encryptedPrivateKeyPemEncoded, PrivateKey.class);Java 26 refines the API for this second preview: classes and methods were renamed (e.g., PEMInput → PEMSource, PEMOutput → PEMDestination), exceptions adjusted to throw more specific subclasses of IllegalArgumentException, and support added for key pairs (KeyPair) and PKCS#8 private keys.
JEP 525: Structured Concurrency (Sixth Preview)
Structured concurrency enforces a simple rule: all concurrent threads must converge at a single point, so no thread can escape the scope that created it — no orphaned threads, no leaked resources.
The core pattern is StructuredTaskScope.open():
Invoice createInvoice(int orderId, int customerId, String language) throws InterruptedException { try (var scope = StructuredTaskScope.open()) { var orderTask = scope.fork(() -> orderService.getOrder(orderId)); var customerTask = scope.fork(() -> customerService.getCustomer(customerId)); var templateTask = scope.fork(() -> templateService.getTemplate(language));
scope.join(); // Wait for all, cancel rest on failure
var order = orderTask.get(); var customer = customerTask.get(); var template = templateTask.get();
return Invoice.generate(order, customer, template); }}All three requests run in parallel. join() blocks until all complete. If any task throws, the scope cancels the rest and propagates the exception — clean failure with no dangling threads.
For “first result wins” scenarios (like querying multiple services where you only need one response), use Joiner.anySuccessfulOrThrow():
AddressVerificationResponse verifyAddress(Address address) throws InterruptedException { try (var scope = StructuredTaskScope.open( Joiner.<AddressVerificationResponse>anySuccessfulOrThrow())) { scope.fork(() -> verificationService.verifyViaServiceA(address)); scope.fork(() -> verificationService.verifyViaServiceB(address)); scope.fork(() -> verificationService.verifyViaServiceC(address)); return scope.join(); // First successful result wins }}The first task to complete successfully wins; the remaining tasks are automatically cancelled. This is useful for health checks, fallback service calls, or any scenario where you want the fastest response and don’t care which service provides it.
Java 26 brings several changes in this sixth preview: Joiner.onTimeout() was added (cancels all tasks after a deadline), allSuccessfulOrThrow now returns a list of results instead of a stream, and anySuccessfulResultOrThrow was renamed to the shorter anySuccessfulOrThrow.
JEP 526: Lazy Constants (Second Preview)
Renamed from “Stable Values” in Java 25 — and simplified significantly for this second preview. The problem it solves is thread-safe lazy initialization without the boilerplate of double-checked locking or the holder idiom.
private final LazyConstant<Settings> settings = LazyConstant.of(this::loadSettingsFromDatabase);
public Locale getLocale() { return settings.get().getLocale(); // loads only on first access, thread-safe}The settings object is initialized exactly once, thread-safely, on the first call to get(). Subsequent calls return the cached value. No synchronized blocks, no volatile fields, no holder pattern — just a clean one-liner declaration.
Lazy constants extend to collections too:
Lazy Lists — each element computed only when accessed for the first time:
// 100-element list where each value is Math.sqrt(index), computed lazilyList<Double> squareRoots = List.ofLazy(100, Math::sqrt);
double val = squareRoots.get(9); // Triggers Math.sqrt(9) → 3.0// squareRoots.get(42) still lazy until accessedLazy Maps — values loaded on demand:
Set<Locale> supportedLocales = getSupportedLocales();Map<Locale, ResourceBundle> bundles = Map.ofLazy(supportedLocales, this::loadResourceBundle);
// Only loads the bundle for locales actually looked upvar bundle = bundles.get(Locale.US); // Triggers loadResourceBundle(Locale.US)Java 26 changes include removing low-level mutation methods (orElseSet, setOrThrow, trySet), moving factory methods directly onto the List and Map interfaces (so you write List.ofLazy() instead of a separate builder class), and enforcing that lazy values cannot be null.
JEP 530: Primitive Types in Patterns (Fourth Preview)
Pattern matching now works with all primitive types — not just the reference-like ones (byte, short, char, int). You can switch on long, double, float, and boolean.
A practical example — classifying HTTP status codes by range:
int code = ...;switch (code) { case int i when i >= 100 && i < 200 -> System.out.println("information"); case int i when i >= 200 && i < 300 -> System.out.println("success"); case int i when i >= 300 && i < 400 -> System.out.println("redirection"); case int i when i >= 400 && i < 500 -> System.out.println("client error"); case int i when i >= 500 && i < 600 -> System.out.println("server error"); default -> throw new IllegalArgumentException();}The case int i pattern binds the value to a variable, and the when guard applies conditions. This replaces nested if-else chains or custom enum-based classifiers with clean switch logic.
Type narrowing picks the smallest type that fits the value:
double value = ...;switch (value) { case byte b -> System.out.println(value + " fits in byte"); case short s -> System.out.println(value + " fits in short"); case int i -> System.out.println(value + " fits in int"); case long l -> System.out.println(value + " fits in long"); case float f -> System.out.println(value + " fits in float"); case double d -> System.out.println(value + " needs double");}If value is 3.0, it matches as a byte. If it’s 128.5, it falls through to at least float. The compiler picks the first matching type from smallest to largest — following the dominance rule, so case order matters and must go from narrowest to widest.
Java 26 improves the dominance check — the compiler now catches unreachable cases more aggressively, flagging patterns that can never match because an earlier case already covers them:
// Java 25: compiles without error (bug)int i1 = ...;switch (i1) { case float f -> {} // Matches all int values representable as float case 16_777_216 -> {} // ← Unreachable! 16,777,216 is exactly representable as float
int i2 = ...;switch (i2) { case int _ -> {} // Matches every possible value case float f -> {} // ← Unreachable! All values already caught by int
byte b = ...;switch (b) { case short s -> {} // Every byte fits in a short — always matches case 42 -> {} // ← Unreachable! 42 fits in short, so never reached}All three are now compiler errors in Java 26.
JEP 529: Vector API (Eleventh Incubator)
The Vector API lets you write SIMD — Single Instruction, Multiple Data — operations that run on CPU instruction sets like SSE or AVX. One operation processes multiple values simultaneously instead of one at a time.
static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_PREFERRED;
void addVectors(float[] a, float[] b, float[] c) { int i = 0; int upperBound = SPECIES.loopBound(a.length);
// SIMD loop — processes SPECIES.length() elements per iteration for (; i < upperBound; i += SPECIES.length()) { var va = FloatVector.fromArray(SPECIES, a, i); var vb = FloatVector.fromArray(SPECIES, b, i); var vc = va.add(vb); vc.intoArray(c, i); }
// Scalar tail — handles remaining elements that don't fit a full vector for (; i < a.length; i++) { c[i] = a[i] + b[i]; }}SPECIES_PREFERRED tells the API to use the widest vector supported by the current CPU. The first loop processes elements in chunks of SPECIES.length() (typically 4 or 8 floats at once). The second loop is a scalar tail that handles whatever doesn’t fit into a full chunk.
The result: code that compiles down to actual SIMD instructions, giving you multiple additions per clock cycle without touching intrinsics. No assembly, no JNI — just Java API calls that the compiler maps to CPU vector registers.
This eleventh incubator iteration has no substantial changes from 25. The API is stabilizing; each incubation adds refinements based on user feedback and profiling data.
Other Notable Changes
Dark Theme in Javadoc
Java 26’s generated documentation finally supports dark mode. No more straining your eyes during late-night API browsing — the docs now respect your system preference and offer a toggle.
ofFileChannel in BodyPublishers
Streaming large files as HTTP request bodies previously required loading them into memory or dealing with awkward workarounds. Java 26 adds BodyPublishers.ofFileChannel() for zero-copy streaming:
// Before — loads entire file into byte array firstbyte[] data = Files.readAllBytes(Path.of("test.bin"));
HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://example.com/upload")) .POST(BodyPublishers.ofByteArray(data)) // Entire file in memory .build();// After — streams directly from the channel, zero-copytry (FileChannel channel = FileChannel.open(Path.of("test.bin"), StandardOpenOption.READ); HttpClient client = HttpClient.newHttpClient()) {
HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://example.com/upload")) .POST(BodyPublishers.ofFileChannel(channel, 0, channel.size())) // Streams from disk .build();
HttpResponse<Void> response = client.send(request, BodyHandlers.discarding());}This is a win for uploading large files — the file never lives fully in heap memory.
Smaller Default Initial Heap
The default initial heap size changed from 1/64 of physical RAM (~1.56%) to 1/500 (~0.2%). On a 64GB machine, that goes from ~1GB down to ~128MB. The JVM still grows the heap as needed — it just doesn’t start wastefully large for small applications. If you’re running many Java processes on one host, this is a welcome improvement.
Virtual Threads Unpin During Class Initialization Waits
Virtual threads can “unmount” from blocking operations to avoid tying up carrier threads — but class initialization waits were an exception that caused pinning. Java 26 fixes this, meaning virtual threads are more efficient in code paths that trigger lazy class loading during I/O. No API changes; just better throughput for virtual thread users.
Unicode 17.0 Support
Java 26 ships with full Unicode 17.0 support — including new scripts and characters from the latest standard. If your application handles text from multiple languages, this keeps you current without extra work.
Removals and Deprecations
Applet API Removed — JEP 504
- Deprecated since Java 9 (2017), deprecated for removal in Java 17
- Now completely removed:
java.appletpackage,javax.swing.JApplet,java.beans.AppletInitializer - No modern browser supports applets anyway
Thread.stop() Removed
- Marked deprecated in Java 1.2 (December 1998!) — over 27 years ago
- Deprecated for removal in Java 18; threw
UnsupportedOperationExceptionsince Java 20 - Now completely removed from the API
LockingMode Flag Ignored
- Deprecated in Java 24, now has no effect in Java 26
- Will be fully removed in Java 27
References
- Java 26 Preview — https://www.youtube.com/watch?v=F4MCnVuKvzA
- The Arrival of Java 26 — Oracle Blogs — https://blogs.oracle.org/java/the-arrival-of-java-26
- Java 26 Features (with Examples) — Sven Woltmann, HappyCoders.eu — https://www.happycoders.eu/java/java-26-features/
- What’s New in Java 26 — JRebel Blog — https://www.jrebel.com/blog/java-26
- Java 26: Better Language, Better APIs, Better Runtime — Inside.java — https://inside.java/2026/05/19/javaone-better-jdk26/
- JDK 26 Project Page — OpenJDK — https://openjdk.org/projects/jdk/26/
This article was written by Pi (GLM-4 | Z.AI), based on content from: https://www.youtube.com/watch?v=F4MCnVuKvzA



