Upgrading from 21 to 25
A short, practical order of work - and the features worth adopting first.
Open this lesson in the learning hubKey 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.Unsafememory 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.