# java8-to-25 Companion code for the ankurm.com post **"Java 8 to Java 25 Migration Guide: The Long Jump in One Plan"**: A small Java 8 application that uses nine things that changed, run for real on JDK 8, 17 and 25. Everything quoted in the post comes from a file in [`output/`](output/). ## Tested against | Thing | Version | |---|---| | JDK 8 | Temurin 1.8.0_514-b01 | | JDK 17 | Temurin 17.0.21.1+2 (middle point of a staged path) | | JDK 25 | Temurin 25.0.5.1+2 | | Maven / Gradle | 3.9.11 / 8.14.3 (the old-Gradle failure) | | JAXB / JAX-WS | jakarta.xml.bind-api 4.0.5, jaxb-runtime 4.0.9, jaxws-rt 4.0.5 (bridge: 2.3.3 / 2.3.9 / 2.3.7) | | Nashorn | nashorn-core 15.7 | | OpenRewrite | rewrite-maven-plugin 6.46.1, rewrite-migrate-java 3.42.1 | Linux x86-64, `LANG=C` (so the JDK 8 default charset is US-ASCII; on a UTF-8 or Windows machine that line differs). ## Layout | Path | What it is | |---|---| | `legacy/` | the Java 8 application (`javax.xml.bind`, JAX-WS, `sun.misc`, Nashorn, version parsing, `URLClassLoader` cast, reflection into `java.util`, Security Manager, `Thread.stop`) | | `bridge/` | jars that let the **unchanged** JDK 8 bytecode run on 25 | | `fixed/` | the same application fixed for Java 25 | | `flags/` | the JDK 8 era JVM options that are tried one by one | | `probes/` | TLS and keystore defaults, libraries (Lombok, Mockito, ASM, JaCoCo, Spring Boot 2.7), build tools, javax vs jakarta | | `scripts/` | one script per group of transcripts; `run-all.sh` runs them all | ## Run it ```bash export JDK8=/path/to/jdk8 JDK17=/path/to/jdk17 JDK25=/path/to/jdk25 export GRADLE=/path/to/gradle # optional, for output/24 ./scripts/run-all.sh # needs Maven and Maven Central ``` `MVN_SETTINGS` (a settings.xml) and `REPO` (a Maven repository base URL for the jar downloads) override Maven Central. `output/15` is the OpenRewrite diff; the script makes it on a throwaway copy in `build/`. Port 18099 must be free for the JAX-WS step. Object hash codes and log timestamps differ between runs. ## Output index | File | Shows | |---|---| | 01 | JDK 8 `javac` without `-encoding` on a UTF-8 source | | 02, 03, 03b | the same classes run on 8, on 25, on 17 | | 04, 05 | compiling the sources with JDK 25, and the `--release 8` trap | | 06, 07, 08 | `jdeps --jdk-internals`, `jdeps -verbose:package`, `jdeprscan` | | 09 | JDK 8 JVM options on 8, 17 and 25 | | 10, 11, 12 | GC and heap defaults, TLS and keystore defaults, SHA-1 signed jar | | 13, 27 | unchanged bytecode on 25 with bridge jars and flags; the bridge jars on 8 | | 14 | the fixed application on 25 | | 15, 16, 17 | OpenRewrite `UpgradeToJava25`: diff, build failure, run after one hand edit | | 18 to 22 | Lombok, Mockito, ASM, JaCoCo, Spring Boot 2.7.18 on 25 | | 23, 24 | old Maven compiler levels; Gradle 8.14.3 on 25 | | 25, 26 | `javax` packages left in JDK 25; mixing `javax` annotations with the `jakarta` JAXB runtime |