Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Upgrades and deprecations

Java 11 to 21: What Breaks Along the Way, and Which Order to Take It In

In short

Code that sticks to supported APIs mostly runs unchanged on Java 21. Breakage sits mainly in four places: deep reflection into JDK internals, refused by default since 17; the UTF-8 default charset from 18; System::setSecurityManager, which throws by default from 18; and APIs and tools removed between 12 and 21. I would move production straight to 21, test on 17, and weigh 25, the newer LTS.

How long are Java 11, 17 and 21 supported, and by whom?

Oracle and Eclipse Adoptium each date their own builds, so the same release number ends at different times. Oracle lists 8, 11, 17, 21 and 25 as LTS and plans Java 29 as the next, in September 2027. Adoptium supports each LTS for at least four years, and gives Temurin 11 and 17 the same end. Oracle's dates apply to its commercially supported builds, and those for 17, 21 and 25 are marked "or later".

ReleaseGAOracle Premier Support untilOracle Extended Support untilTemurin builds until
11Sep 2018Sep 2023Jan 2032At least Oct 2027
17Sep 2021Sep 2026Sep 2029At least Oct 2027
21Sep 2023Sep 2028Sep 2031At least Dec 2029
25Sep 2025Sep 2030Sep 2033At least Sep 2031

Checked against: source 16, source 17

Should a Java 11 codebase stop at 17 on the way to 21?

Oracle's guide starts at the target. It says to try the application on JDK 21 first, then update libraries, recompile and run jdeps in parallel. The non-LTS releases between are dead ends: the roadmap treats each as superseded when the next ships, and Temurin lists 16 and 18 to 20 as end of service life.

17 is the only supported stop, and its Oracle Premier Support ended in September 2026. I would make one production move, 11 to 21, and keep a JDK 17 job in CI. By my reading of the release each change landed in, a failure that already shows up on 17 comes from 12 to 17, such as strong encapsulation or a removal; one seen only on 21 comes from 18 to 21, such as the charset or Security Manager default. JEP 411 says the disallow value of java.security.manager arrived in Java 12, so that flag cannot preview the 18 default on 11.

Java 25, out since September 2025, is the newest released LTS. I would still pick 21 when a framework in the build supports 21 but not 25 yet. For code that will sit untouched for years, 25 adds two years of Oracle Premier Support (September 2028 to September 2030) and 21 months of Temurin builds (December 2029 to September 2031), by my arithmetic from the table. The price is four more releases of changes, 22 to 25, including JEP 486: JDK 24 cannot enable a Security Manager at startup or install one at run time.

Checked against: source 5, source 16, source 17, source 9, source 15, source 8, source 1

What can be checked while the code still runs on 11?

JEP 403 suggests running an existing release such as JDK 11 with --illegal-access=warn, then debug for stack traces, then deny. JEP 400 asks for a run with -Dfile.encoding=UTF-8 and a compile with javac -encoding UTF-8 on the current JDK.

The guide adds jdeps -jdkinternals, which flags internal API use but cannot see reflective calls, and jdeprscan, which lists what 21 marks for removal. The third command below, from JEP 400, prints the current default charset.

jdeps -jdkinternals Sample.class
jdeprscan --release 21 -l --for-removal
java -XshowSettings:properties -version 2>&1 | grep file.encoding

Checked against: source 8, source 11, source 5, source 2

What did Java 12 to 16 remove that a Java 11 build might still use?

From the removal chapters of the JDK 21 guide:

  • Nashorn and the jjs tool are gone in 15, after deprecation in 11. JEP 372 says the javax.script API stays.
  • rmic is removed in 15, and biased locking is off by default.
  • The CMS collector is removed in 14. If the VM will not start, the guide says to look for removed GC options.
  • The Pack200 tools and API, and the java.security.acl package, are removed in 14.
  • Old tracing flags are obsolete in 16, for example -XX:+TraceClassLoading, now -Xlog:class+load=info.
  • 16 drops root certificates with 1024-bit RSA keys from cacerts, and SunEC drops legacy curves such as secp256k1.

Checked against: source 3, source 2, source 14, source 5

What does Java 17 refuse that 11 allowed?

Reflection into JDK internals. The 17 guide says JDK 17 is strongly encapsulated, so code touching non-public fields and methods of java.* APIs throws InaccessibleObjectException. --illegal-access is obsolete; any value only prints a warning.

Newer libraries are the guide's first answer. For a tool that cannot be updated, --add-opens grants reflective access to one package and --add-exports exposes one internal API, at your own risk. sun.misc and sun.reflect stay available, the 21 guide says.

JEP 403 lists kinds of code that will fail, among them frameworks calling the protected ClassLoader.defineClass, tools built on com.sun.tools.javac.*, and code using the JDK's internal Xerces or ASM. Annotation processors can fail during compilation, as in the jdk.compiler export error.

17 also removes RMI Activation and deprecates the Security Manager and the Applet API for removal. Enabling a Security Manager on the command line now prints a startup warning that, per JEP 411, cannot be suppressed.

Checked against: source 7, source 4, source 8, source 2, source 3, source 1, source 9

What changes at 18, and what do 19 to 21 add?

18 holds the changes that compile cleanly and surface later.

  • UTF-8 becomes the default charset of the Java SE APIs on all operating systems (JEP 400). Before, Windows used a codepage such as windows-1252. -Dfile.encoding=COMPAT restores the old choice. javac now reads sources as UTF-8 unless -encoding is set.
  • java.security.manager defaults to disallow, so System::setSecurityManager throws UnsupportedOperationException unless the command line sets allow.
  • SHA-1 signed JARs are disabled.
  • Finalization is deprecated for removal but still on; --finalization=disabled turns it off for a trial (JEP 421).
  • 20 makes Thread.stop, suspend and resume throw UnsupportedOperationException and deprecates the java.net.URL constructors; 19 deprecates the Locale constructors.
  • 21 removes java.lang.Compiler, ThreadGroup.allowThreadSuspension and the JAR index feature, and warns when an agent loads into a running JVM. JEP 451 gives a mocking library as an example of one that uses an agent; -XX:+EnableDynamicAgentLoading silences the warning.
  • 21 also adds sequenced collections. JEP 431 warns that names like getFirst() and reversed() can clash with existing methods, and that the covariant reversed() overrides are source and binary incompatible with a class implementing both List and Deque.

Checked against: source 11, source 5, source 9, source 6, source 10, source 3, source 2, source 12, source 1, source 13

Which Gradle, Maven and Lombok versions does a Java 21 build need?

Gradle's matrix gives 8.4 for Java 21 toolchains and 8.5 to run Gradle on 21. Java 11 runs Gradle only up to 8.14.x, and the current 9.9.2 needs a JVM from 17 to 27. I would move to 8.14.x while still on 11, then change the JDK as its own step.

Maven's compiler plugin defaults source and target to 8 whatever JDK runs Maven. Set maven.compiler.release to 21; the parameter exists since plugin 3.6, and Maven's guide says javac then rejects APIs missing from that release. If Maven runs on an older JDK, see the release-version fix.

Lombok's changelog adds initial JDK 21 support in 1.18.30; this fix page covers older versions failing. Spring Boot's Java floor per line is in the Spring Boot 2.7 upgrade route.

Checked against: source 18, source 19, source 20, source 21, source 22, source 5

What else do people ask?

Will Java 11 bytecode run on 21 without recompiling?

Often. The guide says most code and libraries should work on JDK 21 unchanged and suggests running the existing build before recompiling.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. This page reads Oracle's JDK 17 and JDK 21 migration guides, the OpenJDK JEP pages, the Oracle and Adoptium support tables and the Gradle and Maven documentation, all fetched on 21 Nov 2026. I did not migrate a codebase for it. It leaves out third-party libraries other than Lombok, application servers, Android, GraalVM and JDK builds from vendors other than Oracle and Adoptium. Found a mistake? Tell me.

Keep reading

Next step

Have a project in mind?

Tell me about it. A discovery call within 48 hours.