Significant Changes in JDK 25 Release

See JDK 25 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 25.

The following are some of the updates in Java SE 25 and JDK 25:

Language Preview Features

  • Pattern Matching is enhanced by allowing primitive types in all pattern contexts. The instanceof operator and switch expressions and statements are extended to work with all primitive types.

    First previewed in Java SE 23, this feature is re-previewed for this release. There are no significant changes between Java SE 23 and this release.

    See JEP 507: Primitive Types in Patterns, instanceof, and switch (Third Preview) and the following sections in Java Platform, Standard Edition Java Language Updates:

  • Module Import Declarations enable you to succinctly import all of the packages exported by a module. This simplifies the reuse of modular libraries without requiring the importing code to be in a module itself.

    First previewed in Java SE 23, this feature is re-previewed for this release. There are no significant changes between Java SE 23 and this release.

    See JEP 511: Module Import Declarations and Module Import Declarations in Java Platform, Standard Edition Java Language Updates.

  • Compact source files and instance main methods enable students to write their first programs without needing to understand the full set of language features designed for large programs.
    First previewed in Java SE 21 as JEP 445: Unnamed Classes and Instance Main Methods (Preview) and previewed again in Java SE 22, 23, and 24, this feature is permanent in this release with a revised title. In this release:
    • The new IO class for basic console I/O is now in the java.lang package rather than the java.io package. Thus, it is implicitly imported by every source file.
    • The static methods of the IO class are no longer implicitly imported into compact source files. Thus invocations of these methods must name the class, for example, IO.println("Hello, world!"), unless the methods are explicitly imported.
    • The implementation of the IO class is now based upon System.out and System.in rather than the java.io.Console class.

    See JEP 512: Compact Source Files and Instance Main Methods and Compact Source Files and Instance main Methods in Java Platform, Standard Edition Java Language Updates.

  • Flexible Constructor Bodies allow statements in a constructor to appear before an explicit constructor invocation, such as super(..) or this(..). These statements cannot reference the instance under construction, but they can initialize its fields. Initializing fields before invoking another constructor makes a class more reliable when methods are overridden.

    First previewed in Java SE 22 as JEP 447: Statements before super(...) (Preview) and previewed again in Java SE 23 and Java SE 24, this feature is permanent in this release without any significant changes.

    See JEP 513: Flexible Constructor Bodies and Flexible Constructor Bodies in Java Platform, Standard Edition Java Language Updates.

See JEP 12: Preview Features and Preview Language and VM Features in Java Platform, Standard Edition Java Language Updates.

Library Improvements, Previews, and Incubator

  • Structured Concurrency is an API that simplifies concurrent programming. It treats groups of related tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability.

    See JEP 505: Structured Concurrency (Fifth Preview) and Structured Concurrency in Java Platform, Standard Edition Core Libraries.

  • Scoped Values enable a method to share immutable data both with its callees within a thread and with child threads. They are easier to reason about than thread-local variables. They also have lower space and time costs, especially when used together with virtual threads and structured concurrency.

    See JEP 506: Scoped Values and the ScopedValue class in the Java API Specification.

  • Stable Values API hold immutable data. They are treated as constants by the JVM, enabling the same performance optimizations that are enabled by declaring a field final. Compared to final fields, stable values offer greater flexibility as to the timing of their initialization.

    See JEP 502: Stable Values (Preview), StableValue in the Java API Specification, and the Stable Values in Java Platform, Standard Edition Core Libraries.

  • The Vector API expresses vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.

    See JEP 508: Vector API (Tenth Incubator) and JEP 11: Incubator Modules.

Security Libraries
  • An API has been introduced for encoding objects that represent cryptographic keys, certificates, and certificate revocation lists into the widely-used Privacy-Enhanced Mail (PEM) transport format, and for decoding from that format back into objects.

    See JEP 470: PEM Encodings of Cryptographic Objects (Preview) and The DEREncodable Interface in Java Platform, Standard Edition Security Developer's Guide.

  • An API has been introduced for Key Derivation Functions (KDFs), which are cryptographic algorithms for deriving additional keys from a secret key and other data.

    See JEP 510: Key Derivation Function API and The KDF Class in Java Platform, Standard Edition Security Developer's Guide.

Performance and Runtime Improvements

  • The size of object headers in the HotSpot JVM is reduced from 96 and 128 bits to 64 bits on 64-bit architectures. This will reduce heap size, improve deployment density, and increase data locality. This experimental feature is now changed to a product feature.

    See JEP 519: Compact Object Headers.

  • Ahead-of-Time (AOT) Command-Line Ergonomics simplifies the process of creating ahead-of-time (AOT) caches by reducing the complexity of the commands required for common use cases. AOT caches help accelerate the startup of Java applications, making them more efficient and responsive.

    First introduced in JEP 483: Ahead-of-Time Class Loading and Linking, this enhancement brings new AOT-related optimizations to the HotSpot JVM.

    See JEP 514: Ahead-of-Time Command-Line Ergonomics.

  • Ahead-of-Time Method Profiling improves the startup time by making the method-execution profiles from a previous run of an application instantly available when the HotSpot Java Virtual Machine starts. This allows the JIT compiler to generate the native code right at application startup, eliminating the need to wait for profile data to be collected during the current run.

    See JEP 515: Ahead-of-Time Method Profiling.

Monitoring

  • JFR CPU-Time Profiling : JDK Flight Recorder (JFR) has been enhanced to collect more accurate CPU-time profiling data on Linux. This feature is currently experimental.

    See JEP 509: JFR CPU-Time Profiling (Experimental) and JDK Flight Recorder.

  • JFR Cooperative Sampling: Stability of the JDK Flight Recorder (JFR) has been enhanced when it asynchronously samples Java thread stacks by restricting call stack walking to safepoints, while reducing safepoint bias.

    See JEP 518: JFR Cooperative Sampling.

  • JFR Method Timing and Tracing: JDK Flight Recorder (JFR) has been extended to support method timing and tracing using bytecode instrumentation. Timing and tracing method invocations can help to identify performance bottlenecks, optimize code, and find the root causes of bugs.

    See JEP 520: JFR Method Timing & Tracing.

Removals and Warnings for Future Changes

Removal of Experimental Features Graal JIT: The optional experimental Graal JIT compiler has been removed.

For details on removals and deprecations, see Features and Options Removed and Deprecated in JDK 25.

In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 25.