Skip to main content

Java 8 to Java 25 Migration Guide: The Long Jump in One Plan

Upgrade Java 8 to 25 with evidence: one legacy app run on JDK 8, 17 and 25, the real error messages, javax versus jakarta, 33 old JVM options, TLS defaults, library versions, where jdeps and OpenRewrite stop, and a four-stage plan.

You have an application that has run on Java 8 for years, and someone has put “upgrade to Java 25” on the plan. The first attempt usually ends within a minute, with a JVM that refuses to start or a wall of package javax.xml.bind does not exist. Neither is the worst problem. The worst problem is the code that starts, runs and quietly returns something different. This guide takes one small Java 8 application that uses nine old habits, runs it for real on JDK 8, 17 and 25, and fixes it. Every error message and number below was captured from those runs. It is written for teams that are still on Java 8; if you are already on 17, read the Java 17 to Java 25 Migration Guide instead.
Versions used. JDK 8: Temurin 1.8.0_514. JDK 17: Temurin 17.0.21.1. JDK 25 (the LTS, GA September 2025): Temurin 25.0.5.1. Maven 3.9.11, Gradle 8.14.3, OpenRewrite rewrite-migrate-java 3.42.1 with rewrite-maven-plugin 6.46.1, jaxb-runtime 4.0.9, jaxws-rt 4.0.5, nashorn-core 15.7. Linux x86-64 with LANG=C, so results that depend on locale or operating system may differ on your machine.
All code and transcripts are in the java8-to-25 module of the javademos repository.

The jump is big because eight releases of changes arrive at once

Java 8 shipped in 2014. Since then the JDK has been split into modules, has removed several libraries it used to include, has locked away its internal classes, and has changed some defaults. None of those happened between 17 and 25 on this scale, so advice written for that smaller jump will not prepare you.
JDK 9modules, newversion, CLDRJDK 11JAXB andJAX-WS goneJDK 15Nashorn gone(CMS in 14)JDK 17JDK internalsclosedJDK 18UTF-8 is thedefaultJDK 20Thread.stopthrowsJDK 23COMPAT localedata goneJDK 24Security MgrdisabledWhat sits between Java 8 and Java 25Red boxes remove an API you may call. Amber boxes change behaviour underneath code that still compiles.
The timeline is the reason this jump hurts more than any later one: eight separate releases each took something away, and a Java 8 codebase meets all of them on the same afternoon. The practical consequence is that you need a way to sort the failures, not just a list of them. You do not need to learn modules to make this upgrade. Your application can stay on the class path. What you need is to sort every failure into one of three groups.
1. The JVM will not startan old option in a scriptUnrecognized VM option2. Code fails loudlycompile error or exceptionNoClassDefFoundError3. Code runs and lieswrong value, no errormajor=0Three kinds of breakage, in the order you meet themThe first two announce themselves. The third needs a comparison of real output from both JDKs.
This is the mental model for the rest of the page. Each section below belongs to one of these three boxes, and the third box is the one that reaches production, because a green build says nothing about it.

Going deeper

A Java 8 application with nine ordinary habits runs cleanly on Java 8

The sample app is deliberately unremarkable. It writes XML with JAXB, publishes a SOAP service, encodes a token with sun.misc.BASE64Encoder, evaluates a rule in JavaScript, parses the Java version, casts the system class loader, peeks at a private field, installs a Security Manager and kills a thread. A small runner calls each one and carries on after a failure:
    public static void main(String[] args) {
        System.out.println("running on java.version " + System.getProperty("java.version"));
        step("jaxb", () -> OrderXml.toXml(new Order("A-1", 12)));
        step("jaxws", SoapCheck::publishAndReadWsdl);
        step("base64", () -> Tokens.encode("ankur".getBytes("UTF-8")));
        step("nashorn", () -> Rules.discount(12));
        step("version", () -> "major=" + JavaVersion.major());
        step("classloader", () -> "classpath found=" + PluginScanner.classpathEntries());
        step("reflection", () -> "ArrayList capacity=" + Peek.capacity(new ArrayList<>(32)));
        step("securitymanager", Guard::install);
        step("thread.stop", Watchdog::kill);
        System.out.println(Report.lines());
        System.exit(0);
    }

    private static void step(String name, Callable<Object> work) {
Source: legacy/src/main/java/com/ankurm/legacy/App.java. The version parser is worth a good look now, because it comes back later. It assumes every version looks like 1.x:
    public static int major() {
        String v = System.getProperty("java.version");
        return Integer.parseInt(v.split("\\.")[1]);
    }
Source: legacy/src/main/java/com/ankurm/legacy/JavaVersion.java. On JDK 8 everything passes. The lines under the nine steps are a report of formats and character sets, which matter in a few sections:
running on java.version 1.8.0_514
[ok]   jaxb: <order><id>A-1</id><quantity>12</quantity></order>
[ok]   jaxws: WSDL served
[ok]   base64: YW5rdXI=
[ok]   nashorn: BULK
[ok]   version: major=8
[ok]   classloader: classpath found=1
[ok]   reflection: ArrayList capacity=32
[ok]   securitymanager: blocked: plugins may not exit the JVM
[ok]   thread.stop: stopped
date(en_US)     = Mar 5, 2026 2:30 PM
date(de_DE)     = Donnerstag, 5. März 2026
money(en_IN)    = Rs.1,234,567.50
defaultCharset  = US-ASCII
rupee as bytes  = 1 byte(s)
From output/02-run-on-jdk8.txt. One surprise appears even before this run. Without an -encoding flag, the JDK 8 compiler used the machine’s locale and rejected a rupee sign in the source (output/01-jdk8-compile-no-encoding.txt). Since JDK 18 the default charset is UTF-8, so the same file compiles on 25 without the flag.

Going deeper

Run the old classes on Java 25 first: eight steps fail and one lies

The cheapest experiment is to change only the runtime. Take the classes that JDK 8 built and start them with the JDK 25 java command. Nothing is recompiled, so every difference comes from the platform.
running on java.version 25.0.5.1
[FAIL] jaxb: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
[FAIL] jaxws: java.lang.NoClassDefFoundError: javax/xml/ws/Endpoint
[FAIL] base64: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder
[FAIL] nashorn: java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.put(String, Object)" because "<local1>" is null
[ok]   version: major=0
[FAIL] classloader: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
[FAIL] reflection: java.lang.reflect.InaccessibleObjectException: Unable to make field transient java.lang.Object[] java.util.ArrayList.elementData accessible: module java.base does not "opens java.util" to unnamed module @355da254
[FAIL] securitymanager: java.lang.UnsupportedOperationException: Setting a Security Manager is not supported
[FAIL] thread.stop: java.lang.UnsupportedOperationException
date(en_US)     = Mar 5, 2026, 2:30 PM
date(de_DE)     = Donnerstag, 5. März 2026
money(en_IN)    = ₹1,234,567.50
defaultCharset  = UTF-8
rupee as bytes  = 3 byte(s)
From output/03-jdk8-classes-on-jdk25.txt. Eight steps fail with an exception. The ninth, version, reports [ok] and answers major=0, because 25.0.5.1 split on dots has 0 in the second position. Any if (major >= 8) in your code now takes the wrong branch without a word.
StepWhat happenedRemoved or changed inFix
jaxb, jaxwsNoClassDefFoundError11add dependencies
base64NoClassDefFoundError9java.util.Base64, carefully
nashornNullPointerException15add nashorn-core or replace
versionwrong answer9Runtime.version().feature()
classloaderClassCastException9read java.class.path
reflectionInaccessibleObjectException16/17stop doing it; --add-opens meanwhile
securitymanagerUnsupportedOperationException24no in-JVM replacement
thread.stopUnsupportedOperationException20interrupt cooperatively
Note the Nashorn row. The engine lookup does not throw when the engine is missing; it returns null, and the failure appears one line later as a NullPointerException that never mentions Nashorn. On JDK 17 the same classes fail six of those eight: the Security Manager still installs (with a warning) and Thread.stop() still stops (output/03b-jdk8-classes-on-jdk17.txt). Most of the cost of leaving 8 is therefore paid at 17 already.

Going deeper

Compiling on Java 25 is a second, different test

Now recompile the same sources with JDK 25. This finds some problems earlier, with file and line numbers:
$ javac -encoding UTF-8 ...    # JDK 25
src/main/java/com/ankurm/legacy/Order.java:3: error: package javax.xml.bind.annotation does not exist
src/main/java/com/ankurm/legacy/OrderXml.java:4: error: package javax.xml.bind does not exist
src/main/java/com/ankurm/legacy/SoapCheck.java:6: error: package javax.xml.ws does not exist
src/main/java/com/ankurm/legacy/StatusService.java:3: error: package javax.jws does not exist
src/main/java/com/ankurm/legacy/Tokens.java:3: error: cannot find symbol
import sun.misc.BASE64Encoder;
  symbol:   class BASE64Encoder
src/main/java/com/ankurm/legacy/Guard.java:6: warning: [removal] SecurityManager in java.lang has been deprecated and marked for removal
src/main/java/com/ankurm/legacy/Watchdog.java:15: warning: [removal] stop() in Thread has been deprecated and marked for removal
20 errors
4 warnings
From output/04-jdk25-compile.txt (selected lines). The compiler is silent about Nashorn, the version parser, the class loader cast and the reflective access. All four are legal Java. Many teams then try --release 8 to “keep it as before”. It behaves in a way that is easy to misread. With the sun.misc file and the runner left out, JDK 25 compiles the JAXB and JAX-WS classes successfully:
$ javac --release 8 ...    # JDK 25, all sources except Tokens.java and App.java
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
exit status: 0

$ ls r8/com/ankurm/legacy
Guard$1.class
Guard.class
JavaVersion.class
Order.class
OrderXml.class
Peek.class
PluginScanner.class
Report.class
Rules.class
SoapCheck.class
StatusService.class
Watchdog.class
From output/05-jdk25-release8.txt.
Java 8 sourcesimport javax.xml.bindjavac –release 8on JDK 25: exit status 0java on JDK 25NoClassDefFoundErrorThe –release 8 trap–release 8 compiles against a record of the Java 8 API, which still lists JAXB. The runtime is still 25.
Read the picture from left to right: the compiler is checking your code against the old API, and the virtual machine is running it against the new one. Only the second one decides whether a class exists.
A green build with –release 8 does not mean the jar will run on 25. It proves your code matches the Java 8 API. It also dropped the two [removal] warnings about the Security Manager and Thread.stop() from the output above. Only running the code on 25 tests the runtime.
Going deeper: why sun.misc fails under –release 8 when javax.xml.bind does not --release N compiles against the documented, exported API of release N. JAXB was part of the Java SE 8 API; sun.misc.BASE64Encoder was never a documented API. The same run shows the second half:
$ javac --release 8 Tokens.java
src/main/java/com/ankurm/legacy/Tokens.java:3: error: package sun.misc does not exist
import sun.misc.BASE64Encoder;
               ^
src/main/java/com/ankurm/legacy/Tokens.java:8: error: cannot find symbol
        return new BASE64Encoder().encode(raw);
                   ^
  symbol:   class BASE64Encoder
  location: class Tokens
2 errors
From output/05-jdk25-release8.txt.

Going deeper

javax to jakarta applies to some javax packages, not all of them

Java 11 removed the Java EE modules from the JDK, so JAXB, JAX-WS and friends are now ordinary dependencies. Their current versions use the package prefix jakarta. That has produced a common mistake: replacing every javax. in the codebase. A short program asking JDK 25 what it still exports settles it:
exported javax.* packages in this JDK: 99
  javax.sql                    in the JDK, keep javax
  javax.crypto                 in the JDK, keep javax
  javax.net.ssl                in the JDK, keep javax
  javax.naming                 in the JDK, keep javax
  javax.management             in the JDK, keep javax
  javax.script                 in the JDK, keep javax
  javax.swing                  in the JDK, keep javax
  javax.xml.parsers            in the JDK, keep javax
  javax.transaction.xa         in the JDK, keep javax
  javax.annotation.processing  in the JDK, keep javax
  javax.xml.bind               not in the JDK
  javax.xml.ws                 not in the JDK
  javax.jws                    not in the JDK
  javax.activation             not in the JDK
  javax.annotation             not in the JDK
  javax.transaction            not in the JDK
  javax.servlet                not in the JDK
  javax.persistence            not in the JDK
  javax.validation             not in the JDK
From output/25-javax-packages.txt.
Stays javax (part of the JDK)javax.sql javax.cryptojavax.net.ssl javax.namingjavax.management javax.scriptjavax.swing javax.xml.parsersjavax.transaction.xaLeft the JDK or never in itjavax.xml.bind javax.xml.wsjavax.jws javax.activationjavax.annotation javax.transactionjavax.servlet javax.persistencejavax.validation“Replace javax with jakarta” is wrong as a search-and-replaceOnly the right-hand column ever moves to jakarta.*. Renaming anything on the left breaks the build.
The split follows ownership. Packages on the left belong to Java SE and keep their names. Packages on the right belonged to Java EE, which moved to the Eclipse Foundation and took the jakarta.* namespace. For JAXB you therefore have two valid fixes. The 2.3.x artifacts (confusingly named jakarta.xml.bind-api) still contain javax.xml.bind, so old code keeps working with only a dependency added. The 4.x artifacts contain jakarta.xml.bind and need new imports. Do not mix them. Here a bean keeps its old annotation while a 4.x runtime does the work:
import java.io.StringWriter;
import jakarta.xml.bind.JAXBContext;
import javax.xml.bind.annotation.XmlRootElement;

public class Mixed {
    @XmlRootElement(name = "order")
    public static class Order {
        public String id = "A-1";
Source: probes/mixed/src/main/java/Mixed.java.
$ java Mixed      # javax annotations on the bean, jakarta JAXB runtime
Exception in thread "main" jakarta.xml.bind.MarshalException
[com.sun.istack.SAXException2: unable to marshal type "Mixed$Order" as an element because it is missing an @XmlRootElement annotation]
From output/26-mixed-namespaces.txt (selected lines).
The error says the annotation is missing while you are looking straight at it. The 4.x runtime only reads jakarta.xml.bind.annotation annotations. A javax one is just an unrelated annotation to it.
Frameworks force the larger version of this move. Spring Boot 3 and later use Jakarta EE namespaces, and Spring Boot 4.2 requires Java 17 or newer. That is a framework migration of its own, covered in Automating javax to jakarta and Boot 3 to 4 upgrades with OpenRewrite.
Going deeper: the dependencies for each choice Keep javax imports, add jars (bridge/pom.xml):
    <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>2.3.3</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <version>2.3.9</version>
    </dependency>
    <dependency>
      <groupId>com.sun.xml.ws</groupId>
      <artifactId>jaxws-rt</artifactId>
      <version>2.3.7</version>
    </dependency>
    <dependency>
      <groupId>jakarta.jws</groupId>
      <artifactId>jakarta.jws-api</artifactId>
      <version>2.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.openjdk.nashorn</groupId>
      <artifactId>nashorn-core</artifactId>
      <version>15.7</version>
    </dependency>
  </dependencies>
Source: bridge/pom.xml. Move to jakarta imports (fixed/pom.xml):
    <!-- JAXB: API plus an implementation. Both left the JDK in Java 11. -->
    <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>4.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <version>4.0.9</version>
      <scope>runtime</scope>
    </dependency>
    <!-- JAX-WS: jaxws-rt brings the API (jakarta.xml.ws, jakarta.jws) and the runtime. -->
    <dependency>
      <groupId>com.sun.xml.ws</groupId>
      <artifactId>jaxws-rt</artifactId>
      <version>4.0.5</version>
    </dependency>
    <!-- Nashorn, now a standalone OpenJDK project. -->
    <dependency>
      <groupId>org.openjdk.nashorn</groupId>
      <artifactId>nashorn-core</artifactId>
      <version>15.7</version>
    </dependency>
  </dependencies>
Source: fixed/pom.xml.

Going deeper

The JDK now refuses access to its own internals

Two of the failures come from code reaching into the JDK. The reflective read of ArrayList.elementData now ends in this:
[FAIL] reflection: java.lang.reflect.InaccessibleObjectException: Unable to make field transient java.lang.Object[] java.util.ArrayList.elementData accessible: module java.base does not "opens java.util" to unnamed module @355da254
[FAIL] classloader: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
From output/03-jdk8-classes-on-jdk25.txt. This is the module system at work. JDK packages are closed to reflection from your code unless a package is explicitly opened. Your code lives in the “unnamed module” (the class path), which is the name in the message. The class loader cast fails for a related reason: since Java 9 the application loader is an internal class that is not a URLClassLoader. If you meet InaccessibleObjectException inside a library, the real fix is a newer version of that library. As a temporary measure, open exactly the package the message names: --add-opens java.base/java.util=ALL-UNNAMED. The old catch-all, --illegal-access=permit, no longer does anything:
################ --illegal-access=permit
JDK 8  exit=1
    Unrecognized option: --illegal-access=permit
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
JDK 17  exit=0
    OpenJDK 64-Bit Server VM warning: Ignoring option --illegal-access=permit; support was removed in 17.0
    OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing)
From output/09-jvm-flags.txt. --add-opens does nothing for the class loader cast, which is a type error and has to be fixed in code:
    public static int classpathEntries() {
        String[] entries = System.getProperty("java.class.path").split(File.pathSeparator);
        return entries.length > 0 ? 1 : 0;
    }
Source: fixed/src/main/java/com/ankurm/fixed/PluginScanner.java. You do not have to write a module-info.java to upgrade. If you later want modules, Java Modules (JPMS) for Working Developers explains exports, opens and jdeps.

Going deeper

Each removed API has a fix, and one obvious fix is subtly wrong

JAXB and JAX-WS need dependencies, as above. Nashorn continues as a standalone OpenJDK library, nashorn-core; adding it let the unchanged rule code run again. The version parser becomes one call:
    public static int major() {
        return Runtime.version().feature();
    }
Source: fixed/src/main/java/com/ankurm/fixed/JavaVersion.java. Base64 looks like the easiest of all, and is where output changes without any error. sun.misc.BASE64Encoder wrapped long output into lines. Encoding 100 bytes on JDK 8, where old and new APIs exist side by side:
$ java Wrap      # JDK 8, encoding 100 zero bytes
sun.misc.BASE64Encoder     length=137  chars 70..84: AAAAAA\nAAAAAA
Base64.getEncoder()        length=136  chars 70..84: AAAAAAAAAAAAAA
Base64.getMimeEncoder()    length=138  chars 70..84: AAAAAA\r\nAAAA
getMimeEncoder(76, \n)    length=137  chars 70..84: AAAAAA\nAAAAAA
lengths 0..600: getMimeEncoder(76, \n) differs from sun.misc at: 57 114 171 228 285 342 399 456 513 570
From output/28-base64-wrapping.txt.
getEncoder() is not a drop-in replacement. It never wraps. getMimeEncoder() wraps, but with \r\n instead of \n. Even the closest form differs when the input length is a multiple of 57, because the old class also appended a final newline there. If anything compares, signs or stores these strings, test with your real data.
    static Base64.Encoder lf() {
        return Base64.getMimeEncoder(76, new byte[] {'\n'});
Source: probes/base64/Wrap.java. The Security Manager has no in-process replacement. If you used it to contain plugins, you need an operating-system boundary: a separate process or a container. The fixed app shows the smallest form, where a child’s System.exit cannot take the host down:
    public static String runIsolated() throws Exception {
        String java = Paths.get(System.getProperty("java.home"), "bin", "java").toString();
        Process child = new ProcessBuilder(java, "-cp", System.getProperty("java.class.path"),
                Plugin.class.getName()).inheritIO().start();
        return "child exit code " + child.waitFor() + ", host still running";
    }
Source: fixed/src/main/java/com/ankurm/fixed/Guard.java. That isolates the exit call only. It is not a sandbox: the child can still read files and open sockets. Thread.stop() becomes interruption, and the worker has to cooperate. The original loop swallowed InterruptedException, so swapping stop() for interrupt() alone leaves it running:
        Thread worker = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt(); // restore the flag so the loop ends
                }
            }
        });
        worker.setDaemon(true);
Source: fixed/src/main/java/com/ankurm/fixed/Watchdog.java. With all fixes in place the application runs on 25. The JAX-WS runtime still prints an Unsafe deprecation warning, which is a future upgrade to watch:
running on java.version 25.0.5.1
[ok]   jaxb: <order><id>A-1</id><quantity>12</quantity></order>
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.sun.xml.ws.model.InjectorHelper (file:./fixed/target/dependency/jaxws-rt-4.0.5.jar)
WARNING: Please consider reporting this to the maintainers of class com.sun.xml.ws.model.InjectorHelper
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
<timestamp> com.sun.xml.ws.server.MonitorBase createMOM
INFO: Monitoring is not available, starting up without monitoring.
[ok]   jaxws: WSDL served
[ok]   base64: YW5rdXI=
[ok]   nashorn: BULK
[ok]   version: major=25
[ok]   classloader: classpath found=1
[ok]   reflection: list size=0 (capacity no longer read)
[ok]   securitymanager: child exit code 3, host still running
[ok]   thread.stop: stopped
date(en_US)     = Mar 5, 2026 2:30 PM
date(de_DE)     = Donnerstag, 5. März 2026
money(en_IN)    = Rs.1,234,567.50
charset used    = UTF-8
rupee as bytes  = 3 byte(s)
From output/14-fixed-on-jdk25.txt.

Going deeper

Some things throw nothing and still change

Compare the bottom of the three runs. These lines come from identical bytecode:
LineJDK 8JDK 17JDK 25
date, en_USMar 5, 2026 2:30 PMMar 5, 2026, 2:30 PMMar 5, 2026, 2:30 PM
money, en_INRs.1,234,567.50₹1,234,567.50₹1,234,567.50
default charsetUS-ASCIIUS-ASCIIUTF-8
rupee sign as bytes113
The values come from output/02-run-on-jdk8.txt, output/03b and output/03. Java 9 switched the default locale data to the Unicode CLDR set. Later CLDR updates put a narrow no-break space (U+202F) before “PM”, which looks like a space and is not one, so string comparisons and parsers fail. The charset change in Java 18 affects every getBytes() and FileReader without an explicit charset. Two stopgap properties existed. One still works and one is gone: -Dfile.encoding=COMPAT restored the old charset on 25, while asking for the old locale data only produced a warning:
WARNING: COMPAT locale provider has been removed
money(en_IN)    = ₹1,234,567.50
defaultCharset  = US-ASCII
From output/13-bridge-on-jdk25.txt (selected lines). The durable fix is to say what you mean wherever another system reads the text:
        DateTimeFormatter us = DateTimeFormatter.ofPattern("MMM d, yyyy h:mm a", Locale.US);
        DateTimeFormatter de = DateTimeFormatter.ofPattern("EEEE, d. MMMM yyyy", Locale.GERMANY);
        DecimalFormat inr = new DecimalFormat("'Rs.'#,##0.00", DecimalFormatSymbols.getInstance(Locale.US));
Source: fixed/src/main/java/com/ankurm/fixed/Report.java.
Capture output on 8 before you upgrade. Run your reports, exports and file writers on 8, keep the bytes, run them again on 25 and diff. No compiler or analysis tool in this article reported any of the four differences in the table.

Going deeper

Your start-up script is probably the first thing to fail

Java 8 production scripts collect options for years. I tried 33 common ones, one at a time, as java <flag> -version. On JDK 25, 26 of them stop the JVM from starting, 4 print a warning and 3 are accepted silently (-XX:+AggressiveHeap, -XX:+UseStringDeduplication, -XX:+DisableExplicitGC). On JDK 17, 22 were fatal.
################ -XX:+UseConcMarkSweepGC
JDK 8  exit=0
JDK 17  exit=1
    Unrecognized VM option 'UseConcMarkSweepGC'
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
JDK 25  exit=1
    Unrecognized VM option 'UseConcMarkSweepGC'
From output/09-jvm-flags.txt.
Java 8 optionOn JDK 25Use instead
-XX:MaxPermSize, PermSizefataldelete; -XX:MaxMetaspaceSize only if you need a cap
UseConcMarkSweepGC and CMS tuning, UseParNewGC, -Xincgcfatalstart from G1 defaults and re-tune from measurements
UseParallelOldGCfatal-XX:+UseParallelGC
PrintGCDateStamps, PrintGCTimeStamps, PrintTenuringDistribution, GC log rotationfatal-Xlog:gc*:file=gc.log:time,uptime:filecount=5,filesize=20m
PrintGCDetails, -Xloggcwarning-Xlog:gc*
AggressiveOpts, UseBiasedLocking, UseFastAccessorMethods, -d64, -Xfuture, UnlockCommercialFeaturesfataldelete
-Djava.ext.dirs, -Djava.endorsed.dirs, -Xbootclasspath/pfatalclass path, dependencies, --patch-module
-Djava.security.managerfataldelete
The replacement spellings in the last column are standard JDK syntax; the script tests the old options, not these. The complete result for all three JDKs is in output/09-jvm-flags.txt, and the list is in flags/jdk8-flags.txt so you can paste in your own. The collector also changes under you. On two CPUs JDK 8 picked Parallel GC and JDK 17 and 25 picked G1. With -XX:ActiveProcessorCount=1, 17 and 25 picked Serial, and 8 used a serial heap layout. The default maximum heap was identical on all three on this machine, and compact object headers are off by default on 25.
################ JDK 25, -XX:ActiveProcessorCount=2
    MaxHeapSize              1610612736
    UseCompactObjectHeaders  false
    UseCompressedOops        true
    UseContainerSupport      true
    UseG1GC                  true
    UseParallelGC            false
    UseSerialGC              false
    UseStringDeduplication   false
From output/10-gc-defaults.txt.

Going deeper

TLS and certificates: check the partner on the other end

Updated Java 8 builds have already absorbed much of the security tightening, so compare against your actual patch level. Against Temurin 8u514, TLS 1.0 and 1.1 are disabled on 8, 17 and 25 alike, and a SHA-1 signed jar is “treated as unsigned” by both the 8 and the 25 jarsigner (output/12-sha1-signed-jar.txt). What differs:
DefaultJDK 8u514JDK 17 and 25
keystore typejkspkcs12
TLS_RSA_* cipher suites enabled6 of 330 of 31
SHA-1 handshake signaturesnot listed as disabledlisted as disabled
A server or load balancer that only offers RSA key exchange stops working. In the probe, a client that offers only one such suite fails:
[ok]   TLSv1.2 default suites -> TLSv1.2 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
[FAIL] TLSv1.1 only -> javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
[FAIL] TLS_RSA_WITH_AES_128_GCM_SHA256 -> javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
The three handshakes on JDK 25, from output/11-tls-crypto-defaults.txt. The message “protocol is disabled or cipher suites are inappropriate” is the same for an old protocol and a banned suite, so run with -Djavax.net.debug=ssl,handshake to see which. The fix belongs on the other endpoint. Re-enabling algorithms by editing jdk.tls.disabledAlgorithms should be a dated exception with an owner.

Going deeper

Old build tools and libraries fail before your code gets a chance

A Java 25 class file has major version 69. Any tool that reads or writes bytecode has to know that number. These are real results on JDK 25:
Tool or libraryFailedWorked
Maven source/target1.71.8 (with an obsolete warning)
Gradle8.14.3docs say 9.1.0 or later is needed
Lombok1.18.20, 1.18.361.18.38, 1.18.40, 1.18.48
Mockito (Byte Buddy)5.14.2 (1.15.11)5.25.0 (1.18.17); 2.28.2 and 4.11.0 also mocked a concrete class
ASM9.2, 9.7.19.8, 9.11.1
JaCoCo agent0.8.110.8.13, 0.8.14, 0.8.16
Spring Boot 2.7.18app compiled --release 25app compiled --release 8
“Worked” means the small probe passed, not that your build will. The newest versions in the table are the safe choice. The transcripts are numbered 18 to 24 in the output folder.
$ gradle compileJava      # Gradle 8.14.3, JAVA_HOME = JDK 25
* What went wrong:
BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 69
From output/24-gradle-on-25.txt (selected lines).
################ mockito-core 5.14.2 (byte-buddy 1.15.11)
Mockito cannot mock this class: class MockDemo$PriceService.
Caused by: java.lang.IllegalArgumentException: Java 25 (69) is not supported by the current version of Byte Buddy which officially supports Java 24 (68) - update Byte Buddy or set net.bytebuddy.experimental as a VM property
From output/19-mockito.txt.
Lombok on the class path may silently stop running. Since JDK 23, javac no longer runs annotation processors just because they are on the class path. The symptom is a missing constructor or getter, with no mention of Lombok:
################ lombok 1.18.48 on the class path only (what a pom with just the dependency does)
./probes/libs/LombokBean.java:7: error: constructor LombokBean in class LombokBean cannot be applied to given types;
        System.out.println("getter says " + new LombokBean("ankur").getName());
                                            ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
From output/18-lombok.txt. Declare processors explicitly, in Maven through annotationProcessorPaths on the compiler plugin. JaCoCo fails more quietly still: 0.8.11 prints an error, the program carries on, and that class is not instrumented. The Spring Boot result is the most useful one for planning. The same 2.7.18 context starts on JDK 25 when the application is compiled for 8, and fails when compiled for 25:
################ Spring Boot 2.7.18 on JDK 25, application compiled with --release 8
context started
From output/22-boot27.txt.
################ Spring Boot 2.7.18 on JDK 25, application compiled with --release 25
Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [./build/libs/bt/app/DemoApp.class]; nested exception is java.lang.IllegalArgumentE
From output/22-boot27.txt (the exception line is cut at 260 characters by the script). That was a minimal context with component scanning. It shows that the runtime and the bytecode level can move separately, not that 2.7 is supported on 25.
Going deeper: the old compiler level and the Lombok stack trace
################ maven.compiler.source/target=1.7, JDK 25
[ERROR] Source option 7 is no longer supported. Use 8 or later.
[ERROR] Target option 7 is no longer supported. Use 8 or later.
[INFO] BUILD FAILURE
From output/23-maven-old-levels.txt.
################ lombok 1.18.20 with -processorpath
An annotation processor threw an uncaught exception.
Caused by: java.lang.NoSuchFieldException: com.sun.tools.javac.code.TypeTag :: UNKNOWN
From output/18-lombok.txt.

Going deeper

jdeps, jdeprscan and OpenRewrite each see only part of it

jdeps and jdeprscan ship with the JDK and read a built jar. jdeps --jdk-internals reports exactly one of the problems, with a suggested replacement:
$ jdeps --jdk-internals legacy.jar
   com.ankurm.legacy.Tokens                           -> sun.misc.BASE64Encoder                             JDK removed internal API
sun.misc.BASE64Encoder                   Use java.util.Base64 @since 1.8
From output/06-jdeps-jdk-internals.txt (selected lines). jdeps -verbose:package adds the missing packages, marked not found, and jdeprscan --release 25 reports the missing classes and the deprecated calls:
Jar file legacy.jar:
class com/ankurm/legacy/Guard$1 extends deprecated class java/lang/SecurityManager (forRemoval=true)
class com/ankurm/legacy/Guard$1 uses deprecated class java/lang/SecurityManager (forRemoval=true)
class com/ankurm/legacy/Guard uses deprecated method java/lang/System::setSecurityManager(Ljava/lang/SecurityManager;)V (forRemoval=true)
error: cannot find class javax/xml/bind/JAXBContext
error: cannot find class javax/xml/bind/Marshaller
class com/ankurm/legacy/Report uses deprecated method java/util/Locale::<init>(Ljava/lang/String;Ljava/lang/String;)V 
error: cannot find class javax/xml/ws/Endpoint
class com/ankurm/legacy/SoapCheck uses deprecated method java/net/URL::<init>(Ljava/lang/String;)V 
error: cannot find class sun/misc/BASE64Encoder
class com/ankurm/legacy/Watchdog uses deprecated method java/lang/Thread::stop()V (forRemoval=true)
From output/08-jdeprscan.txt. OpenRewrite changes source code. Running UpgradeToJava25 on a copy of the app (on JDK 8, where it still built) edited five files: it raised the compiler level to 25, added JAXB and JAX-WS 2.3.x dependencies, replaced BASE64Encoder with getEncoder(), moved new Locale to Locale.of and turned System.out.println into IO.println. It also did this to the watchdog:
-        worker.stop();
+        /*
+         * `Thread.stop()` always throws a `new UnsupportedOperationException()` in Java 21+.
+         * For detailed migration instructions see the migration guide available at
+         * https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/doc-files/threadPrimitiveDeprecation.html
+         */
+        throw new UnsupportedOperationException();
From output/15-openrewrite-diff.txt. The next line of that method is now unreachable, so the project no longer compiles:
$ mvn clean compile      # JDK 25, straight after the recipe
[ERROR] src/main/java/com/ankurm/legacy/Watchdog.java:[21,9] unreachable statement
[INFO] BUILD FAILURE
From output/16-openrewrite-build.txt. After one hand edit to that line, the rewritten project still fails like this:
[ok]   jaxb: <order><id>A-1</id><quantity>12</quantity></order>
[FAIL] jaxws: javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
[FAIL] nashorn: java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.put(String, Object)" because "js" is null
[ok]   version: major=0
[FAIL] classloader: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
[FAIL] reflection: java.lang.reflect.InaccessibleObjectException: Unable to make field transient java.lang.Object[] java.util.ArrayList.elementData accessible: module java.base does not "opens java.util" to unnamed module @1517365b
[FAIL] securitymanager: java.lang.UnsupportedOperationException: Setting a Security Manager is not supported
[ok]   thread.stop: still alive
From output/17-openrewrite-run.txt. The JAX-WS failure is a scope problem: the recipe added jaxws-rt as provided, which suits an application server and not a plain java -cp run. Changing it to runtime fixed it when I tried. thread.stop: still alive is my one-line interrupt() meeting the swallowing loop.
Problemjavac 25jdepsjdeprscanOpenRewrite recipe
JAXB, JAX-WS missingerrornot found (verbose)cannot find classdependencies added; JAX-WS scope needed a fix
sun.misc.BASE64Encodererroryescannot find classreplaced; line wrapping lost
Nashorn––––
version parsing––––
class loader cast––––
reflection into JDK––––
Security Managerwarning–yes–
Thread.stop()warning–yesreplaced with a throw; build broke
dates, currency, charset––––
This table describes one small app and these versions. It is still the argument for the plan below: tools shorten the work, and running the code on 25 finds the rest.
Going deeper: running the same tools on your project The commands are in scripts/02-analyse.sh and scripts/05-bridge-fixed-rewrite.sh:
JAVA_HOME=$JDK8 $MVN -q -U org.openrewrite.maven:rewrite-maven-plugin:6.46.1:run \
  -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:3.42.1 \
  -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava25 -Drewrite.exportDatatables=false > ../rewrite.log 2>&1 || { tail -20 ../rewrite.log; exit 1; }
Source: scripts/05-bridge-fixed-rewrite.sh. The full diff is output/15-openrewrite-diff.txt. Review it like a colleague’s pull request. For a framework migration, run narrower recipes in separate commits.

Going deeper

Aim straight at 25, but get there in four stages

The usual question is “should we go through 11 and 17?” You do not need to deploy them. The measurements above show that 17 already contains most of the breaking changes (six of the eight failures, 22 of the 26 fatal flags), so stopping there means doing most of the work and then scheduling a second project. Use 17 as a stop only if a framework or vendor product you cannot yet replace supports 17 and not 25.
1. Still on 8ship the fixes thatalready work on 82. Run on 25old bytecode plusjars and flags (test)3. Build on 25new tools, –release 8frameworks unchanged4. Modernisejakarta, new framework,–release 25One target, four stagesEvery stage ends in something you can deploy or roll back. The target JDK never changes.
Staging the work is what keeps this safe. Each box changes one thing, so when something breaks you know which change did it. Stage 1, while production is on 8. Remove start-up options you do not need, stop calling Thread.stop() and the Security Manager, make format and charset explicit, and add JAXB and JAX-WS as dependencies. The 2.3.x jars ran fine alongside JDK 8:
$ java -cp classes-built-by-jdk8:bridge-jars-without-nashorn com.ankurm.legacy.App      # JDK 8
[ok]   jaxb: <order><id>A-1</id><quantity>12</quantity></order>
[ok]   jaxws: WSDL served
From output/27-bridge-jars-on-jdk8.txt (selected lines). Stage 2, in a test environment. Run the unchanged bytecode on 25 with those jars, nashorn-core and a few flags. This shrinks eight failures to the ones that need code:
$ java --add-opens java.base/java.util=ALL-UNNAMED -Dfile.encoding=COMPAT -Djava.locale.providers=COMPAT \
       -cp classes-built-by-jdk8:bridge-jars com.ankurm.legacy.App      # JDK 25
[ok]   jaxb: <order><id>A-1</id><quantity>12</quantity></order>
[ok]   jaxws: WSDL served
[FAIL] base64: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder
[ok]   nashorn: BULK
[ok]   version: major=0
[FAIL] classloader: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
[ok]   reflection: ArrayList capacity=32
[FAIL] securitymanager: java.lang.UnsupportedOperationException: Setting a Security Manager is not supported
[FAIL] thread.stop: java.lang.UnsupportedOperationException
From output/13-bridge-on-jdk25.txt (selected lines). Stage 3, build with JDK 25. Upgrade Maven or Gradle plugins and test libraries, fix compile errors, and keep the bytecode level low while old frameworks remain. Stage 4 moves the framework to a Jakarta-based line and then raises --release.
Going deeper: a checklist you can copy
  • Save today’s JVM options and run each through java <flag> -version on 25.
  • Run jdeps --jdk-internals, jdeps -verbose:package and jdeprscan --release 25 on every jar, including third-party ones.
  • Search sources for java.version, URLClassLoader, setAccessible, getEngineByName, SecurityManager, .stop(), sun., getBytes(), FileReader, SimpleDateFormat.
  • Capture files, reports and API responses on 8 and diff them on 25.
  • List every TLS peer and test a handshake from JDK 25.
  • Upgrade build plugins, Lombok, Mockito, JaCoCo and anything built on ASM; declare annotation processors.
  • Re-measure memory, GC pauses and start-up with the new default collector.
  • Keep a rollback that does not require rebuilding.
Should you do this now? If the application is maintained and receives traffic from outside, yes: staying on 8 means older frameworks and libraries every year. If it is frozen, internal, nobody can test it, and a supported Java 8 distribution covers it, upgrading without tests can be riskier than waiting. Write that down as a decision with a review date, and start stage 1 anyway, because it is safe on 8.

Going deeper

Further reading

No Comments yet!

This site uses Akismet to reduce spam. Learn how your comment data is processed.