What’s New in JDK 25? A Deep Dive into Java 25’s Latest Features
JDK 25 introduces sixteen major enhancements—including preview language features, new library APIs, performance and runtime improvements, and expanded security options—along with numerous smaller updates, all detailed in the official release notes and JEP specifications.
Language enhancements (JEP 507, 511, 512, 513)
JEP 507 adds primitive types to pattern matching, instanceof, and switch so that all primitive types can be used in patterns. This is a preview language feature.
JEP 511 introduces module import declarations, allowing a module to import all packages exported by another module without requiring the importing code to be modular.
JEP 512 provides compact source files and instance main methods, enabling small programs to be written without the boilerplate required for large applications.
JEP 513 permits statements before an explicit super(..) or this(..) call in a constructor, allowing field initialization prior to delegating to another constructor.
Library enhancements
Structured concurrency (preview, JEP 505) adds a preview API that treats a group of related tasks running on multiple threads as a single unit, simplifying error handling, cancellation, and observability.
Scoped values (JEP 506) introduces an API for immutable data that can be shared between a thread and its children, offering lower space‑time cost than thread‑local variables, especially when used with virtual threads (JEP 444) and structured concurrency.
Stable values (preview, JEP 502) defines a stable‑value API whose objects are treated as constants by the JVM, providing the same optimization as final fields but with more flexible initialization.
Vector API (10th incubator, JEP 508) adds an API for expressing vector computations that the runtime can compile to optimal CPU instructions, delivering performance superior to equivalent scalar code.
PEM encodings of cryptographic objects (preview, JEP 470) adds an API to encode/decode keys, certificates, and CRLs in PEM format.
Key Derivation Function API (JEP 510) introduces a KDF API for deriving additional keys from a secret and other data.
Additional library changes include new getChars(int, int, char[], int) methods in CharSequence and CharBuffer, a connectionLabel() method in java.net.http.HttpResponse that returns an opaque label identifying the underlying connection, and limiting methods on HttpResponse.BodyHandlers and BodySubscribers to bound the number of response‑body bytes accepted.
ZIP file‑system creation now supports a read‑only mode via the accessMode property with values readOnly or readWrite (e.g.,
FileSystem zipfs = FileSystems.newFileSystem(pathToZipFile, Map.of("accessMode","readOnly"));).
Performance and runtime improvements
Compact object headers (JEP 519) reduce the object header size on 64‑bit HotSpot from 96‑128 bits to 64 bits, decreasing heap size and improving data locality. The feature is disabled by default and must be enabled with -XX:+UseCompactObjectHeaders.
Ahead‑of‑time command‑line ergonomics (JEP 514) simplifies the creation of AOT caches, speeding up application start‑up.
AOT method profiling (JEP 515) makes profiling data from a previous run available at JVM start, allowing the JIT compiler to generate native code earlier.
JFR CPU‑time profiling (experimental, JEP 509) enables more accurate CPU‑time measurements on Linux.
JFR cooperative sampling (JEP 518) improves stability of asynchronous stack sampling by walking stacks only at safepoints.
Method timing & tracing (JEP 520) adds bytecode‑instrumented method‑timing events to JFR.
Thread‑dump output now includes lock information (JDK‑8356870). The G1 garbage collector groups regions into shared card sets, reducing remembered‑set overhead (JDK‑8343782).
The java.util.concurrent.ForkJoinPool now implements ScheduledExecutorService and adds submitWithTimeout. As a result, CompletableFuture and SubmissionPublisher default to the common ForkJoinPool when no explicit executor is supplied.
Security and cryptography
TLS key‑material exporters are added to JSSE and SunJSSE ( javax.net.ssl.ExtendedSSLSession) via JDK‑8341346, exposing two new methods:
public SecretKey exportKeyingMaterialKey(String keyAlg, String label, byte[] context, int length) throws SSLKeyException</code><code>public byte[] exportKeyingMaterialData(String label, byte[] context, int length) throws SSLKeyExceptionThe jdk.tls.disabledAlgorithms property now supports TLS‑scope usage constraints (JDK‑8349583), allowing algorithms to be disabled separately for handshake signatures and certificate signatures.
System property stdin.encoding (JDK‑8350703) specifies the charset used when reading characters from System.in. It can be overridden on the command line, e.g., -Dstdin.encoding=UTF-8.
Both java.util.zip.Inflater and java.util.zip.Deflater now implement AutoCloseable (JDK‑8225763), enabling use with try‑with‑resources.
SHAKE128‑256 and SHAKE256‑512 are added as MessageDigest algorithms (JDK‑8354305) in the Sun provider.
SunPKCS11 now supports HKDF‑SHA256, HKDF‑SHA384, and HKDF‑SHA512 for the new KDF API (JDK‑8328119).
Java XML Security is upgraded to version 3.0.5, adding four SHA‑3 based ECDSA signature methods: SignatureMethod.ECDSA_SHA3_224, SignatureMethod.ECDSA_SHA3_256, SignatureMethod.ECDSA_SHA3_384, and SignatureMethod.ECDSA_SHA3_512 (JDK‑8344137).
Monitoring (JFR) enhancements
A new annotation jdk.jfr.Contextual (JDK‑8356698) marks fields in custom JFR events that should be linked to contextual information from other events on the same thread.
The java.security.debug system property now includes thread ID, thread name, source location, and timestamp by default (JDK‑8350689), producing output such as:
componentValue[threadId|threadName|sourceCodeLocation|timestamp]: <debug statement>Other changes
The jar --validate command (JDK‑8345431) now warns about duplicate entries, entries with drive letters, leading slashes, backslashes, “.” or “..” path elements, and mismatched LOC/CEN header order.
UseCompactObjectHeaders is exposed as a product option ( -XX:+/-UseCompactObjectHeaders) without requiring -XX:+UnlockExperimentalVMOptions. Two additional CDS archive files ( classes_coh.jsa and classes_nocoops_coh.jsa) are provided to preserve launch performance when the option is enabled.
Release notes
JDK 25 includes hundreds of performance, stability, and security fixes tracked in the OpenJDK bug system. Oracle commits to long‑term support through September 2033.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
JakartaEE China Community
JakartaEE China Community, official website: jakarta.ee/zh/community/china; gitee.com/jakarta-ee-china; space.bilibili.com/518946941; reply "Join group" to get QR code
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
