Upgrading from 17 to 21
A practical order of work, and the one change that gives most of the benefit.
Open this lesson in the learning hubKey points
- Start by compiling and running on 21 with no source changes - 17 to 21 is a mild jump.
- Fix agent and build-plugin compatibility first; that is where most failures actually appear.
- Then adopt virtual threads at the edges - the request executor - not deep inside library code.
- Replace
synchronizedaround blocking calls withReentrantLockbefore you turn them on. - Leave preview features out of production; adopt the finalised ones - patterns and sequenced collections.
Upgrade the runtime first and adopt features second - separating them makes failures diagnosable.
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 21 Course course, and every lesson in it is listed on the Java 21 Course contents page.