Video in progress

How do you plan moving 40 services running on Java 8 to Java 21?

First an inventory (jdeps, library versions), then get the build green on the new JDK, then swap the runtime, and finally adopt the new language features. The biggest obstacles: javax to jakarta, strong encapsulation, removed APIs, and outdated libraries.

📖 Answer

This isn't a language question, it's a dependency and operations question. I split it into waves. In practice most of the time goes into step 0 and the jakarta move.

  1. Inventory (1-2 weeks).
  • For each service: the Spring/Hibernate version, the jdeps --jdk-internals output, any use of sun.* / Unsafe, agents (APM, Lombok, bytecode tools).
  • A table: which service has which obstacle.
  1. Known breakages:
  • the Java EE modules were removed in Java 11: JAXB, JAX-WS, javax.annotation need a separate dependency;
  • Java 16-17: reflection into internal APIs is closed by default (JEP 396, 403), so old Lombok, Mockito, Groovy and some APM agents fall over;
  • Spring Boot 3 = Java 17+ and the jakarta.* namespace. This is usually the biggest code change; OpenRewrite recipes automate a lot of it;
  • Java 18: the default charset became UTF-8, so file/console reading behavior may change;
  • Nashorn (Java 15), the Security Manager (deprecated in 17), and others.
  1. Separating build from runtime. First try running the old code directly on the new JDK runtime, not with --release 8: many problems show up at runtime. Then move to --release 17/21.

  2. A pilot. One low-risk service that's well covered by tests. Check the JVM flags: old GC flags (CMS was removed) will keep the JVM from starting. Compare container memory and GC (G1 is the default) behavior in metrics.

  3. The platform. A shared parent POM/BOM, a base Docker image, updating the CI image centrally: if 40 teams each do it themselves, you get 40 different solutions.

  4. Waves. By the table above: easy services, then those that depend on shared libraries, then the hardest (old SOAP, custom agents). Each wave gets a canary deploy and a rollback plan.

  5. Language features last. Records, switch, var: after the migration, in separate PRs. If you mix them, it gets hard to find the cause of a regression.

The measure of success isn't the number of services but the share of production traffic still on the old JDK.