JDK 25 reached general availability on 16 September 2025. It is the next LTS release after 21, so this is the version most of my Spring Boot services will move to over the next year. I read through the JEPs of 22 to 25 and picked the ones that change something for a normal backend service. This is not a full list.
Virtual threads no longer pin on synchronized
This one came in JDK 24 (JEP 491), but if you go from 21 to 25 you get it now. In Java 21, a virtual thread that blocked inside a synchronized block kept its carrier thread. I wrote last year about finding these places and replacing them with ReentrantLock. In 24 and later, virtual threads can unmount inside synchronized too.
So for me this is the biggest reason to move. Libraries that use synchronized around I/O stop being a problem. Pinning still exists in a few cases (for example native code), so jdk.VirtualThreadPinned JFR events are still worth a look.
Compact object headers
JEP 519 makes compact object headers a product feature in 25. Object headers get smaller on 64-bit, which reduces heap use for applications with many small objects. It is not on by default:
java -XX:+UseCompactObjectHeaders -jar app.jar
I plan to test this on one service with a lot of small objects and compare heap usage after a GC. I have no numbers yet, so I cannot say how much it helps for my workloads.
AOT cache for faster startup
JDK 24 added an ahead-of-time cache for loaded and linked classes, and JDK 25 makes it easier to create (JEP 514). You do a training run, then start with the cache:
# training run: run the app with typical work, then stop it
java -XX:AOTCacheOutput=app.aot -jar app.jar
# production start
java -XX:AOTCache=app.aot -jar app.jar
The cache must be created with the same JDK and the same classpath. In a Docker build this means creating it in the image build, not on the developer machine. I have not tried this with a Spring Boot fat jar yet. That is next on my list, because startup time matters for a few small services that start on demand.
Scoped values
Scoped values are final in 25. They are a replacement for many ThreadLocal uses: a value that is visible inside a call and its children, and that cannot be changed.
static final ScopedValue<String> REQUEST_ID = ScopedValue.newInstance();
void handle(Request req) {
ScopedValue.where(REQUEST_ID, req.id()).run(() -> process(req));
}
void process(Request req) {
log.info("processing {}", REQUEST_ID.get());
}
With virtual threads and many short tasks, this is cheaper and clearer than ThreadLocal. Frameworks will probably use it before application code does. I will not rewrite existing ThreadLocal code just for this.
Simpler main methods
JEP 512 is final. A small program can be:
void main() {
IO.println("hello");
}
Save it as Hello.java and run java Hello.java. No class, no static, no String[] args. This is for teaching and for small scripts. I like it for one-off tools that I used to write in Python, for example a script that reads a CSV export and checks it.
Other changes worth knowing
- Flexible constructor bodies (JEP 513): you can write statements before
super(...), for example to validate arguments. - Module import declarations (JEP 511):
import module java.base;imports all exported packages of a module. Nice for scripts. I would not use it in large code bases. - The Security Manager is permanently disabled since JDK 24. If an old library still calls
System.setSecurityManager, it will fail. - The 32-bit x86 port is removed in 25. This does not affect a 64-bit Raspberry Pi OS, but check if you still run a 32-bit OS somewhere.
How I will upgrade
- Update build tools and plugins first: Maven or Gradle, the compiler plugin, Lombok, Mockito, Jacoco, anything that reads bytecode. Old versions fail on new class file versions.
- Run the tests on 25 with the same code, still targeting 21 (
--release 21). Fix only what breaks. - Deploy the service on a JDK 25 runtime. Watch memory and GC for a few days.
- Only then switch
--release 25and start using new APIs.
Spring Boot and other frameworks announce support for new Java versions in their release notes. Check your exact version there before you change the production runtime.