Overview of New Features in Java 25

Introduction Java 25 was released on 16th September 2025. It is a long-term support (LTS) release, the successor to Java 21Click to read: Java 21. Its eighteen JDK Enhancement Proposals (JEPs) made Java simpler to start with - small programs no longer need a class declaration - and finalized several features which had been in preview since Java 21 or 22: module imports, flexible constructor bodies and scoped values. It also made applications start faster and use less memory, and added a Key Derivation Function API. This article gives an overview of the new features in Java 25, and then summarizes all the major changes since Java 21, with links to detailed tutorials. Language and libraries
  1. Compact Source Files and Instance Main Methods - JEP 512 - a program can be just void main() { IO.println("Hello"); }, and the new IO class handles console input and output. Read about compact source files and instance main methodsClick to read tutorial: Java 25 Compact Source Files and Instance main Methods.
  2. Module Import Declarations - JEP 511 - import module java.base; imports every package a module exports. Read about module import declarationsClick to read tutorial: Java 25 Module Import Declarations with Examples.
  3. Flexible Constructor Bodies - JEP 513 - statements before super(...) and this(...). Read about flexible constructor bodiesClick to read tutorial: Java 25 Flexible Constructor Bodies with Examples.
  4. Scoped Values - JEP 506 - immutable, bounded sharing of data with called code and child threads, an alternative to ThreadLocal. Read the scoped values tutorialClick to read tutorial: Java 25 Scoped Values Tutorial with Examples.
  5. Key Derivation Function API - JEP 510 - javax.crypto.KDF, with HKDF. Read about the Key Derivation Function APIClick to read tutorial: Java 25 Key Derivation Function (KDF) API Tutorial.
Performance and runtime
  1. Compact Object Headers - JEP 519 - object headers shrink from 12 to 8 bytes with -XX:+UseCompactObjectHeaders. Read about compact object headersClick to read tutorial: Java 25 Compact Object Headers Explained.
  2. Ahead-of-Time Command-Line Ergonomics - JEP 514 and Ahead-of-Time Method Profiling - JEP 515 - an AOT cache is created in one step with -XX:AOTCacheOutput, and stores method profiles so the JIT compiler warms up faster. Read about the AOT cacheClick to read tutorial: AOT Cache in Java 24 and 25: Faster Startup.
  3. Generational Shenandoah - JEP 521 - Shenandoah's generational mode, experimental in Java 24, became a product feature.
  4. JFR improvements - JEPs 509, 518 and 520 - experimental CPU-time profiling on Linux, cooperative sampling for more accurate and safer stack sampling, and method timing and tracing, which records how often and how long chosen methods run without changing the code. See the JFR event streaming tutorialClick to read: JFR event streaming tutorial for how to consume JFR events.
  5. Remove the 32-bit x86 Port - JEP 503 - the JDK no longer supports 32-bit x86 processors.
Previews and incubators
  1. Stable Values (Preview) - JEP 502 - values which are initialized at most once, lazily, yet treated by the JVM as constants for optimization; renamed lazy constants in Java 26.
  2. PEM Encodings of Cryptographic Objects (Preview) - JEP 470 - reading and writing keys and certificates in the PEM text format.
  3. Primitive Types in Patterns, instanceof, and switch (Third Preview) - JEP 507, Structured Concurrency (Fifth Preview) - JEP 505 and Vector API (Tenth Incubator) - JEP 508 - still evolving.
Everything new from Java 21 to Java 25 For teams moving from Java 21 to Java 25, these are the main changes which became standard across the four releases -
AreaFeature (release)
LanguageUnnamed variables and patternsClick to read tutorial: Java 22 Unnamed Variables and Patterns with _ (22), compact source files and instance main methodsClick to read tutorial: Java 25 Compact Source Files and Instance main Methods (25), module importsClick to read tutorial: Java 25 Module Import Declarations with Examples (25), flexible constructor bodiesClick to read tutorial: Java 25 Flexible Constructor Bodies with Examples (25)
LibrariesForeign Function & Memory APIClick to read tutorial: Java 22 Foreign Function & Memory API Tutorial (22), stream gatherersClick to read tutorial: Java 24 Stream Gatherers Tutorial with Examples (24), Class-File APIClick to read tutorial: Java 24 Class-File API Tutorial with Examples (24), scoped valuesClick to read tutorial: Java 25 Scoped Values Tutorial with Examples (25)
ConcurrencyVirtual threads without pinning in synchronizedClick to read tutorial: Java 24: Virtual Threads in synchronized Without Pinning (24)
SecurityML-KEM and ML-DSAClick to read tutorial: Java 24 Quantum-Resistant Crypto: ML-KEM and ML-DSA (24), KDF APIClick to read tutorial: Java 25 Key Derivation Function (KDF) API Tutorial (25), Security Manager permanently disabled (24)
Startup and memoryAOT cacheClick to read tutorial: AOT Cache in Java 24 and 25: Faster Startup (24, 25), compact object headersClick to read tutorial: Java 25 Compact Object Headers Explained (25)
ToolsMulti-file source programsClick to read tutorial: Java 22: Run Multi-File Programs Without Compiling (22), Markdown documentation commentsClick to read tutorial: Java 23 Markdown Documentation Comments (23)
Garbage collectionG1 region pinning (22), generational ZGC by default (23) and only (24), generational Shenandoah (25)
Removed or restrictedString templates preview withdrawn (23), 32-bit x86 ports (24, 25), warnings for JNI and Unsafe memory access (24)
Each release also has its own overview: Java 22Click to read tutorial: Overview of New Features in Java 22, Java 23Click to read tutorial: Overview of New Features in Java 23 and Java 24Click to read tutorial: Overview of New Features in Java 24.
Upgrading from Java 21 to 25
  • Security Manager: code which calls System.setSecurityManager() fails on Java 24 and later; remove it.
  • Native access and Unsafe: applications using JNI or the FFM API should add --enable-native-access to avoid warnings, and libraries using sun.misc.Unsafe memory access should be upgraded.
  • Virtual threads: if you avoided synchronized because of pinning on Java 21, that is no longer necessary.
  • Quick wins: try -XX:+UseCompactObjectHeaders for lower memory use, and an AOT cache for faster startup - both need only command-line changes.
Summary In this article we went through the new features of Java 25, an LTS release. It finalized compact source files and instance main methods, module imports, flexible constructor bodies, scoped values and the KDF API, made compact object headers and generational Shenandoah product features, simplified the AOT cache, improved JFR, and removed the 32-bit x86 port. We then summarized everything that became standard from Java 22 to 25, and the main points to check when upgrading from Java 21.