Video in progress

You are planning to move the fleet from Java 21 to Java 25 LTS. Which JVM-level changes do you expect to benefit from, and what carries risk?

Benefits: virtual threads no longer pin on synchronized, the AOT cache speeds up startup, compact object headers shrink the heap, and generational Shenandoah became a product feature. Risks: non-generational ZGC and the Security Manager were removed, there are warnings for Unsafe and JNI, and agents and bytecode libraries must support the new class file version.

📖 Answer

I look at this not as a "list of new features" but as "what changes in our fleet".

The expected benefits (I confirm each by measuring):

  • Virtual threads (JEP 491, JDK 24). Blocking inside synchronized no longer ties up the carrier. For teams that had to stop a virtual thread rollout in Java 21 because of pinning, this is the main reason.
  • AOT cache (JEP 483, 514, 515). It stores classes in a loaded state and method profiles, so startup and warm-up get shorter. Significant for services with autoscaling.
  • Compact object headers (JEP 519). The header goes from 12 bytes to 8. In services with many small objects the heap can shrink by 10-20%. It is not the default yet, so test it on a canary with -XX:+UseCompactObjectHeaders.
  • Generational Shenandoah as a product feature (JEP 521).

The risks:

  • Non-generational ZGC was removed (JDK 24): -XX:-ZGenerational no longer works.
  • The Security Manager was disabled completely (JDK 24), so sandbox code that relied on it won't work.
  • Unsafe memory methods give a warning (JDK 24), and using JNI warns too (--enable-native-access). The logs fill up, and it is a signal for a future deny.
  • The 32-bit x86 port was removed, so check exotic environments.
  • ByteBuddy, ASM, Mockito, JaCoCo and APM agents must be on a version that supports Java 25 class files. This is where most breakage happens.

The plan:

  1. Build and test all services on 25 in CI (a matrix).
  2. A PrintFlagsFinal diff and cleaning up the flags in the base image.
  3. Pilot services: one with virtual threads, one with a big heap, one that scales quickly.
  4. Canary waves, with before and after: p99, RSS, GC CPU, startup.

I turn on each new feature (compact headers, AOT cache) separately from the version move, otherwise you can't tell where a regression came from.