Upgrading from 21 to 25

Java 25 Course · lesson 14 of 16 · 4 min read

A short, practical order of work - and the features worth adopting first.

Open this lesson in the learning hub

Key points

  • Both are LTS, so this is a supported hop; do it as a runtime bump with no source changes first.
  • Check anything using sun.misc.Unsafe memory access - that wind-down began in 23.
  • Re-check agents and build plugins, the usual source of upgrade failures.
  • Adopt in this order: scoped values where you use ThreadLocal, then flexible constructors, then module imports.
  • Turn on compact object headers and measure - it is a config change with a real heap saving.

Bump the runtime and prove it in production before you touch a single new language feature.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Java 25 Course course, and every lesson in it is listed on the Java 25 Course contents page.