Scrivio Interview library
ScenarioAdvanced6 min read · updated 12 November 2026

Upgrading 200 services from Java 11 to 21 shows dozens of failures from libraries using deep reflection into java.base. How do you plan the upgrade?

I would treat it as a programme, not 200 separate fights: scan everything with jdeps --jdk-internals and a CI build on Java 21 to find the failures, fix most of them by upgrading the libraries that do the reflection, such as Lombok, Mockito, Byte Buddy and old Spring versions, and allow --add-opens flags only as tracked, temporary exceptions with owners. Then move services in waves, starting with the ones whose dependencies are newest, while a CI job keeps every service tested on Java 21 from the start.

Why this question is asked

Big runtime upgrades rarely fail because of one hard problem; they fail because hundreds of small ones are found late, by each team on its own. Interviewers ask this scenario to see whether we can turn a messy technical problem into a plan with measurement, ownership and an order of work. In this answer, we will see why these failures happen, how to find them all before anyone deploys, how to fix them properly, how to manage the exceptions that remain, and how to order the waves.

1Why the Failures Appear Between 11 and 21

On Java 11, deep reflection into JDK classes still worked by default: the JVM printed a warning and carried on, because --illegal-access=permit was the default. Java 16 changed the default to deny and Java 17 removed the option, so on 21 the same code throws InaccessibleObjectException. Libraries that generate classes at run time, mock objects or patch bytecode were the heaviest users of these tricks, which is why the same few names show up in almost every stack trace.

The second source is class file versions. Byte Buddy, ASM and annotation processors like Lombok read or generate bytecode, and an old version simply does not understand the class file format of Java 21, which is version 65. That failure looks different, often an IllegalArgumentException about an unsupported class file major version, but it is fixed the same way.

2Finding Every Problem Before Anyone Deploys

First, we collect the facts across all 200 services. jdeps reports static uses of internal APIs, and a CI job that builds and tests on Java 21 catches the reflective ones, which jdeps cannot see because they use class names as strings.

Properties
# Static scan of one service and its libraries
jdeps --jdk-internals --multi-release 21 --class-path 'target/lib/*' target/app.jar
# app.jar -> java.base
# com.example.Foo -> sun.misc.BASE64Encoder JDK internal API (removed)
# Warning: JDK internal APIs are unsupported...
# Extra CI job: same build, Java 21 toolchain, allowed to fail at first
mvn -B verify -Djava.version=21 # or a Gradle toolchain set to 21

Notice that the CI job should run early and for everyone, even before a service is scheduled to move. At first it may be red for many services; that is fine, because it turns an unknown risk into a list. We aggregate the results into one dashboard: service, failing library, version in use, version that fixes it. Usually the same ten or fifteen libraries explain most of the failures.

3Fixing by Upgrading Libraries, Not by Adding Flags

Most of the failures are fixed by moving to a library version that supports Java 21. Lombok needs a recent 1.18 release, Mockito 5 bundles a Byte Buddy that knows Java 21, and Spring Framework 5.3 or Spring Boot 3 are needed instead of older Spring lines. Build tools matter too: Gradle, the Maven compiler and surefire plugins, JaCoCo and other agents all have minimum versions for Java 21, so check your version.

The reason to prefer upgrades is that a flag only hides the symptom. --add-opens java.base/java.lang=ALL-UNNAMED opens the whole package to every library on the class path, and the next JDK may tighten the rules further. An upgraded library uses supported APIs and keeps working. A shared bill of materials, such as a parent POM or a Gradle platform owned by the platform team, lets us raise these versions once for many services.

4Managing the Exceptions That Remain

Some libraries will have no fixed version yet, or a service cannot upgrade a library quickly. Then we allow a flag, but on our terms. Every --add-opens or --add-exports is listed in one central file with the service, the library that needs it, an owner and a review date. The build reads the list, so a flag that is not in it fails the build, and the platform team can see how many exceptions exist and track them towards zero.

This matters because flags that live only in a startup script are forgotten. A year later, nobody knows why java.base/sun.nio.ch is open, and nobody dares remove it.

5Upgrading in Waves

With the facts in hand, we schedule the move. The first wave is the services with the newest dependencies, typically on Spring Boot 3 already, where Java 21 often works with no changes. They prove the base images, the build pipelines, monitoring and JVM flags such as memory settings and GC logging, at low risk. Each later wave tackles services that need library upgrades, and the last wave holds the long tail of old stacks that need real work.

Each wave goes to production gradually, with the usual canary and rollback, and we compare latency, memory and error rates against Java 11. Then we remove Java 11 from the base images, so new services cannot start on it.

Step throughThe upgrade programme
  1. Scan all servicesjdeps --jdk-internals and a Java 21 CI job
  2. Group failures by libraryOne dashboard, fixed versions listed
  3. Upgrade shared BOMLombok, Mockito, Byte Buddy, Spring
  4. Still failing after the upgrade?
    YesAdd a tracked --add-opens with ownerNoService is ready
  5. Wave 1: newest stacksProves images, pipelines, flags
  6. Later wavesServices needing upgrades, then the long tail
  7. Remove Java 11 imagesNo new service starts on 11

7 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Why not just add --add-opens for everything and move on?

Because it trades a visible problem for an invisible one. Broad flags open JDK packages to every library, undo the security and integrity benefits of encapsulation, and may break again on the next release. They also hide which libraries are out of date. A short, tracked list of exceptions is acceptable; a blanket flag in every startup script is not.

How long should the programme take?

It depends on how old the stacks are, but the shape is predictable: a few weeks to scan and build the dashboard, the first wave within a month or two, and most services within two or three quarters. The long tail of services with very old frameworks can take longer and may need its own plan, such as a rewrite or retirement.

What else changes between 11 and 21 besides encapsulation?

Some APIs were removed, such as the Nashorn JavaScript engine in 15 and parts of the Security Manager use, the default GC behaviour and container ergonomics improved, and the class file version changed. We also check JVM flags in startup scripts, because removed flags such as CMS options stop the JVM from starting.

7Conclusion

In this answer, we saw that the failures come from libraries doing deep reflection or reading new class files, which Java 11 tolerated and Java 17 and later refuse. We find them all first with jdeps and an early Java 21 CI job, group them by library, and fix most of them through library upgrades in a shared bill of materials. The few remaining --add-opens flags are tracked centrally with owners, and services move in waves starting with the newest stacks, so the risky work comes last and is done with experience.

What to say in the interviewAbout 90 seconds aloud

Open with

First I would explain where the failures come from. On Java 11, deep reflection into java.base still worked with a warning, but since 17 it is denied and the option to relax it globally is gone, so libraries that reflect into the JDK, or that read class files and do not know version 65, fail.

Then, if they want more

Then I would find everything before anyone deploys: run jdeps --jdk-internals across all 200 services and their libraries, and add a CI job that builds and tests every service on Java 21 from day one, allowed to fail at first.

That gives one dashboard, and in my experience the failures cluster in a handful of libraries such as Lombok, Mockito, Byte Buddy, old Spring versions and build plugins. So the main fix is upgrading those, ideally once in a shared bill of materials.

Where a library cannot be upgraded yet, I allow a specific --add-opens, but only as a tracked exception in a central list with an owner and review date, and the build refuses flags that are not listed.

Then I move services in waves, starting with the ones on the newest dependencies to prove the images, pipelines and monitoring, and leave the oldest stacks for last. Finally, we retire the Java 11 base images so nothing new starts on 11.

About this answer

Last updated
12 November 2026
Versions it names
Java 21, Java 11, Java 17, Spring Boot 3
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Upgrading 200 services from Java 11 to 21 shows dozens of failures from libraries using...": https://scrivio-interview-library.netlify.app/java/modules/3c0c87b03e/