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, OpenRewriteAll code and transcripts are in the java8-to-25 module of the javademos repository.rewrite-migrate-java3.42.1 withrewrite-maven-plugin6.46.1, jaxb-runtime 4.0.9, jaxws-rt 4.0.5, nashorn-core 15.7. Linux x86-64 withLANG=C, so results that depend on locale or operating system may differ on your machine.
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.Going deeper
- JEP 223: New version-string scheme
- JEP 261: Module system
- JEP 320: Remove the Java EE and CORBA modules
- Oracle JDK 25 Migration Guide
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 withsun.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
- The whole legacy application
- JEP 400: UTF-8 by Default
- Java 11 features with examples, for what arrived in the first LTS after 8
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 25java 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.
| Step | What happened | Removed or changed in | Fix |
|---|---|---|---|
| jaxb, jaxws | NoClassDefFoundError | 11 | add dependencies |
| base64 | NoClassDefFoundError | 9 | java.util.Base64, carefully |
| nashorn | NullPointerException | 15 | add nashorn-core or replace |
| version | wrong answer | 9 | Runtime.version().feature() |
| classloader | ClassCastException | 9 | read java.class.path |
| reflection | InaccessibleObjectException | 16/17 | stop doing it; --add-opens meanwhile |
| securitymanager | UnsupportedOperationException | 24 | no in-JVM replacement |
| thread.stop | UnsupportedOperationException | 20 | interrupt cooperatively |
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
- JEP 372: Remove the Nashorn JavaScript Engine
- JEP 486: Permanently Disable the Security Manager
- Java 21 to 25 LTS features, for what you gain at the other end
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.
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 andThread.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
- The java command reference for JDK 25
- scripts/01-legacy.sh runs all of the compile and run experiments
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 prefixjakarta. 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.
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 readsFrameworks 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.jakarta.xml.bind.annotationannotations. Ajavaxone is just an unrelated annotation to it.
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
- Spring Boot system requirements
- Hibernate 5 to 7 migration cheat sheet, if your persistence layer moves too
- Spring Boot 4.2 upgrade checklist
The JDK now refuses access to its own internals
Two of the failures come from code reaching into the JDK. The reflective read ofArrayList.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
- JEP 396: Strongly Encapsulate JDK Internals by Default
- JEP 403: Strongly Encapsulate JDK Internals
- sun.misc.Unsafe memory access is going away (the next internal API to go)
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\ninstead 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
- The fixed application
- sun.misc.Unsafe memory access is going away
- Date and Calendar to java.time migration
Some things throw nothing and still change
Compare the bottom of the three runs. These lines come from identical bytecode:| Line | JDK 8 | JDK 17 | JDK 25 |
|---|---|---|---|
| date, en_US | Mar 5, 2026 2:30 PM | Mar 5, 2026, 2:30 PM | Mar 5, 2026, 2:30 PM |
| money, en_IN | Rs.1,234,567.50 | ₹1,234,567.50 | ₹1,234,567.50 |
| default charset | US-ASCII | US-ASCII | UTF-8 |
| rupee sign as bytes | 1 | 1 | 3 |
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
- JEP 252: Use CLDR Locale Data by Default
- JEP 400: UTF-8 by Default
- Moving from Date and Calendar to java.time
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, asjava <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 option | On JDK 25 | Use instead |
|---|---|---|
-XX:MaxPermSize, PermSize | fatal | delete; -XX:MaxMetaspaceSize only if you need a cap |
UseConcMarkSweepGC and CMS tuning, UseParNewGC, -Xincgc | fatal | start from G1 defaults and re-tune from measurements |
UseParallelOldGC | fatal | -XX:+UseParallelGC |
PrintGCDateStamps, PrintGCTimeStamps, PrintTenuringDistribution, GC log rotation | fatal | -Xlog:gc*:file=gc.log:time,uptime:filecount=5,filesize=20m |
PrintGCDetails, -Xloggc | warning | -Xlog:gc* |
AggressiveOpts, UseBiasedLocking, UseFastAccessorMethods, -d64, -Xfuture, UnlockCommercialFeatures | fatal | delete |
-Djava.ext.dirs, -Djava.endorsed.dirs, -Xbootclasspath/p | fatal | class path, dependencies, --patch-module |
-Djava.security.manager | fatal | delete |
-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
- JEP 271: Unified GC Logging
- JEP 363: Remove the Concurrent Mark Sweep Garbage Collector
- Java 17 to Java 25 Migration Guide for GC log and option changes after 17
- output/10-gc-defaults.txt for all three JDKs
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 25jarsigner (output/12-sha1-signed-jar.txt). What differs:
| Default | JDK 8u514 | JDK 17 and 25 |
|---|---|---|
| keystore type | jks | pkcs12 |
TLS_RSA_* cipher suites enabled | 6 of 33 | 0 of 31 |
| SHA-1 handshake signatures | not listed as disabled | listed as disabled |
[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
- probes/tls/CryptoDefaults.java compiles on 8; point it at your JDKs
- What else moved between 17 and 25
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 library | Failed | Worked |
|---|---|---|
Maven source/target | 1.7 | 1.8 (with an obsolete warning) |
| Gradle | 8.14.3 | docs say 9.1.0 or later is needed |
| Lombok | 1.18.20, 1.18.36 | 1.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 |
| ASM | 9.2, 9.7.1 | 9.8, 9.11.1 |
| JaCoCo agent | 0.8.11 | 0.8.13, 0.8.14, 0.8.16 |
| Spring Boot 2.7.18 | app compiled --release 25 | app compiled --release 8 |
$ 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.
| Problem | javac 25 | jdeps | jdeprscan | OpenRewrite recipe |
|---|---|---|---|---|
| JAXB, JAX-WS missing | error | not found (verbose) | cannot find class | dependencies added; JAX-WS scope needed a fix |
sun.misc.BASE64Encoder | error | yes | cannot find class | replaced; line wrapping lost |
| Nashorn | – | – | – | – |
| version parsing | – | – | – | – |
| class loader cast | – | – | – | – |
| reflection into JDK | – | – | – | – |
| Security Manager | warning | – | yes | – |
Thread.stop() | warning | – | yes | replaced with a throw; build broke |
| dates, currency, charset | – | – | – | – |
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
- OpenRewrite UpgradeToJava25 recipe
- The Thread.stop replacement recipe
- jdeps
- jdeprscan
- Automating javax to jakarta and Boot 3 to 4 upgrades with OpenRewrite
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.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> -versionon 25. - Run
jdeps --jdk-internals,jdeps -verbose:packageandjdeprscan --release 25on 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
- AI prompts playbook for Java upgrades
- Spring Boot 3.x end of life and the landing plan
- scripts/run-all.sh regenerates every transcript
Further reading
- Companion module: java8-to-25
- Java 17 to Java 25 Migration Guide
- Automating javax to jakarta and Boot 3 to 4 upgrades with OpenRewrite
- Java Modules (JPMS) for Working Developers
- sun.misc.Unsafe memory access is going away
- Java 21 to 25 LTS features
- Oracle JDK 25 Migration Guide
- JEP 320: Remove the Java EE and CORBA Modules
- JEP 411: Deprecate the Security Manager for Removal
- JEP 486: Permanently Disable the Security Manager
No Comments yet!