From 94f8a0e003597c9838a63eab7092646c6ab28991 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 23:45:00 +0530 Subject: [PATCH] Add java8-to-25 module: legacy Java 8 app run on JDK 8, 17 and 25, tool coverage, JVM flags, libraries, OpenRewrite and the fixed version Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_017ic4b6vDJ5fWY5uEZaJFNi --- README.md | 1 + java8-to-25/.gitignore | 2 + java8-to-25/README.md | 61 ++++ java8-to-25/bridge/pom.xml | 40 +++ java8-to-25/fixed/pom.xml | 51 +++ .../src/main/java/com/ankurm/fixed/App.java | 29 ++ .../src/main/java/com/ankurm/fixed/Guard.java | 22 ++ .../java/com/ankurm/fixed/JavaVersion.java | 8 + .../src/main/java/com/ankurm/fixed/Order.java | 20 ++ .../main/java/com/ankurm/fixed/OrderXml.java | 15 + .../src/main/java/com/ankurm/fixed/Peek.java | 13 + .../java/com/ankurm/fixed/PluginScanner.java | 11 + .../main/java/com/ankurm/fixed/Report.java | 32 ++ .../src/main/java/com/ankurm/fixed/Rules.java | 13 + .../main/java/com/ankurm/fixed/SoapCheck.java | 19 + .../java/com/ankurm/fixed/StatusService.java | 13 + .../main/java/com/ankurm/fixed/Tokens.java | 10 + .../main/java/com/ankurm/fixed/Watchdog.java | 22 ++ java8-to-25/flags/jdk8-flags.txt | 33 ++ java8-to-25/legacy/pom.xml | 15 + .../src/main/java/com/ankurm/legacy/App.java | 30 ++ .../main/java/com/ankurm/legacy/Guard.java | 21 ++ .../java/com/ankurm/legacy/JavaVersion.java | 9 + .../main/java/com/ankurm/legacy/Order.java | 20 ++ .../main/java/com/ankurm/legacy/OrderXml.java | 15 + .../src/main/java/com/ankurm/legacy/Peek.java | 13 + .../java/com/ankurm/legacy/PluginScanner.java | 12 + .../main/java/com/ankurm/legacy/Report.java | 37 ++ .../main/java/com/ankurm/legacy/Rules.java | 13 + .../java/com/ankurm/legacy/SoapCheck.java | 19 + .../java/com/ankurm/legacy/StatusService.java | 13 + .../main/java/com/ankurm/legacy/Tokens.java | 10 + .../main/java/com/ankurm/legacy/Watchdog.java | 19 + .../output/01-jdk8-compile-no-encoding.txt | 11 + java8-to-25/output/02-run-on-jdk8.txt | 21 ++ .../output/03-jdk8-classes-on-jdk25.txt | 21 ++ .../output/03b-jdk8-classes-on-jdk17.txt | 20 ++ java8-to-25/output/04-jdk25-compile.txt | 97 +++++ java8-to-25/output/05-jdk25-release8.txt | 31 ++ java8-to-25/output/06-jdeps-jdk-internals.txt | 13 + java8-to-25/output/07-jdeps-packages.txt | 21 ++ java8-to-25/output/08-jdeprscan.txt | 12 + java8-to-25/output/09-jvm-flags.txt | 334 ++++++++++++++++++ java8-to-25/output/10-gc-defaults.txt | 53 +++ java8-to-25/output/11-tls-crypto-defaults.txt | 93 +++++ java8-to-25/output/12-sha1-signed-jar.txt | 10 + java8-to-25/output/13-bridge-on-jdk25.txt | 25 ++ java8-to-25/output/14-fixed-on-jdk25.txt | 22 ++ java8-to-25/output/15-openrewrite-diff.txt | 131 +++++++ java8-to-25/output/16-openrewrite-build.txt | 4 + java8-to-25/output/17-openrewrite-run.txt | 16 + java8-to-25/output/18-lombok.txt | 20 ++ java8-to-25/output/19-mockito.txt | 9 + java8-to-25/output/20-asm.txt | 8 + java8-to-25/output/21-jacoco.txt | 9 + java8-to-25/output/22-boot27.txt | 6 + java8-to-25/output/23-maven-old-levels.txt | 11 + java8-to-25/output/24-gradle-on-25.txt | 12 + java8-to-25/output/25-javax-packages.txt | 21 ++ java8-to-25/output/26-mixed-namespaces.txt | 6 + java8-to-25/output/27-bridge-jars-on-jdk8.txt | 16 + java8-to-25/probes/javax/JavaxMap.java | 20 ++ java8-to-25/probes/libs/AsmRead.java | 9 + java8-to-25/probes/libs/Hello.java | 5 + java8-to-25/probes/libs/LombokBean.java | 9 + java8-to-25/probes/libs/MockDemo.java | 14 + .../probes/libs/boot27/app/DemoApp.java | 13 + .../probes/libs/boot27/app/Greeter.java | 6 + java8-to-25/probes/libs/boot27/pom.xml | 17 + java8-to-25/probes/mixed/pom.xml | 27 ++ .../probes/mixed/src/main/java/Mixed.java | 16 + java8-to-25/probes/tls/CryptoDefaults.java | 67 ++++ java8-to-25/scripts/01-legacy.sh | 34 ++ java8-to-25/scripts/02-analyse.sh | 8 + java8-to-25/scripts/03-flags.sh | 17 + java8-to-25/scripts/04-gc-crypto.sh | 36 ++ .../scripts/05-bridge-fixed-rewrite.sh | 42 +++ java8-to-25/scripts/06-libraries.sh | 55 +++ java8-to-25/scripts/07-build-tools.sh | 16 + java8-to-25/scripts/08-namespaces.sh | 9 + java8-to-25/scripts/env.sh | 12 + java8-to-25/scripts/run-all.sh | 6 + 82 files changed, 2152 insertions(+) create mode 100644 java8-to-25/.gitignore create mode 100644 java8-to-25/README.md create mode 100644 java8-to-25/bridge/pom.xml create mode 100644 java8-to-25/fixed/pom.xml create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/App.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/Guard.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/JavaVersion.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/Order.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/OrderXml.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/Peek.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/PluginScanner.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/Report.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/Rules.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/SoapCheck.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/StatusService.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/Tokens.java create mode 100644 java8-to-25/fixed/src/main/java/com/ankurm/fixed/Watchdog.java create mode 100644 java8-to-25/flags/jdk8-flags.txt create mode 100644 java8-to-25/legacy/pom.xml create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/App.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/Guard.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/JavaVersion.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/Order.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/OrderXml.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/Peek.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/PluginScanner.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/Report.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/Rules.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/SoapCheck.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/StatusService.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/Tokens.java create mode 100644 java8-to-25/legacy/src/main/java/com/ankurm/legacy/Watchdog.java create mode 100644 java8-to-25/output/01-jdk8-compile-no-encoding.txt create mode 100644 java8-to-25/output/02-run-on-jdk8.txt create mode 100644 java8-to-25/output/03-jdk8-classes-on-jdk25.txt create mode 100644 java8-to-25/output/03b-jdk8-classes-on-jdk17.txt create mode 100644 java8-to-25/output/04-jdk25-compile.txt create mode 100644 java8-to-25/output/05-jdk25-release8.txt create mode 100644 java8-to-25/output/06-jdeps-jdk-internals.txt create mode 100644 java8-to-25/output/07-jdeps-packages.txt create mode 100644 java8-to-25/output/08-jdeprscan.txt create mode 100644 java8-to-25/output/09-jvm-flags.txt create mode 100644 java8-to-25/output/10-gc-defaults.txt create mode 100644 java8-to-25/output/11-tls-crypto-defaults.txt create mode 100644 java8-to-25/output/12-sha1-signed-jar.txt create mode 100644 java8-to-25/output/13-bridge-on-jdk25.txt create mode 100644 java8-to-25/output/14-fixed-on-jdk25.txt create mode 100644 java8-to-25/output/15-openrewrite-diff.txt create mode 100644 java8-to-25/output/16-openrewrite-build.txt create mode 100644 java8-to-25/output/17-openrewrite-run.txt create mode 100644 java8-to-25/output/18-lombok.txt create mode 100644 java8-to-25/output/19-mockito.txt create mode 100644 java8-to-25/output/20-asm.txt create mode 100644 java8-to-25/output/21-jacoco.txt create mode 100644 java8-to-25/output/22-boot27.txt create mode 100644 java8-to-25/output/23-maven-old-levels.txt create mode 100644 java8-to-25/output/24-gradle-on-25.txt create mode 100644 java8-to-25/output/25-javax-packages.txt create mode 100644 java8-to-25/output/26-mixed-namespaces.txt create mode 100644 java8-to-25/output/27-bridge-jars-on-jdk8.txt create mode 100644 java8-to-25/probes/javax/JavaxMap.java create mode 100644 java8-to-25/probes/libs/AsmRead.java create mode 100644 java8-to-25/probes/libs/Hello.java create mode 100644 java8-to-25/probes/libs/LombokBean.java create mode 100644 java8-to-25/probes/libs/MockDemo.java create mode 100644 java8-to-25/probes/libs/boot27/app/DemoApp.java create mode 100644 java8-to-25/probes/libs/boot27/app/Greeter.java create mode 100644 java8-to-25/probes/libs/boot27/pom.xml create mode 100644 java8-to-25/probes/mixed/pom.xml create mode 100644 java8-to-25/probes/mixed/src/main/java/Mixed.java create mode 100644 java8-to-25/probes/tls/CryptoDefaults.java create mode 100755 java8-to-25/scripts/01-legacy.sh create mode 100755 java8-to-25/scripts/02-analyse.sh create mode 100755 java8-to-25/scripts/03-flags.sh create mode 100755 java8-to-25/scripts/04-gc-crypto.sh create mode 100755 java8-to-25/scripts/05-bridge-fixed-rewrite.sh create mode 100755 java8-to-25/scripts/06-libraries.sh create mode 100755 java8-to-25/scripts/07-build-tools.sh create mode 100755 java8-to-25/scripts/08-namespaces.sh create mode 100755 java8-to-25/scripts/env.sh create mode 100755 java8-to-25/scripts/run-all.sh diff --git a/README.md b/README.md index c461ba1..6702ba6 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ These modules keep only sources, a `run.sh` and their transcripts (`output/`). T | [`crac/`](crac) | Spring Boot with CRaC: Checkpoint/Restore Startup Compared with the JDK AOT Cache and a Native Image | one Spring Boot 4.2 service started on a plain JVM, with the JDK AOT cache, from a CRaC checkpoint (at start-up and after warm-up) and as a GraalVM native image, ten interleaved rounds each; the open-file `CheckpointOpenFileException` and its fix, stale environment values, secrets inside the checkpoint, the `warp` and CRIU engines, and a cold page-cache run | | [`java28-features/`](java28-features) | Java 28 Features: The JDK 28 JEP List So Far (With Examples) | one example per JDK 28 JEP on EA build 26, the record rule that changes under `--enable-preview`, PKCS #12/OpenSSL, javac and library behaviour changes against JDK 27 | | [`java21-to-25/`](java21-to-25) | Java 21 to Java 25 Migration Guide: What Breaks, What to Turn On, and the Upgrade Checklist | classes compiled once on 21 and run on 21 and 25, removed APIs, preview classes, a Maven matrix for Lombok/Mockito/JaCoCo/Spring Boot, pinning, compact object headers, containers (`scripts/`, `output/`) | +| [`java8-to-25/`](java8-to-25) | Java 8 to Java 25 Migration Guide: The Long Jump in One Plan | a Java 8 app that breaks nine ways, run on JDK 8, 17 and 25; `javax` vs `jakarta`, the `--release 8` trap, `jdeps`/`jdeprscan` blind spots, 33 JVM options, TLS defaults, Lombok/Mockito/ASM/JaCoCo/Gradle on 25, OpenRewrite `UpgradeToJava25`, bridge classpath and fixed version | ## Captured output (`docs/output/`) diff --git a/java8-to-25/.gitignore b/java8-to-25/.gitignore new file mode 100644 index 0000000..237ede1 --- /dev/null +++ b/java8-to-25/.gitignore @@ -0,0 +1,2 @@ +build/ +target/ diff --git a/java8-to-25/README.md b/java8-to-25/README.md new file mode 100644 index 0000000..65e8ac7 --- /dev/null +++ b/java8-to-25/README.md @@ -0,0 +1,61 @@ +# 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 | diff --git a/java8-to-25/bridge/pom.xml b/java8-to-25/bridge/pom.xml new file mode 100644 index 0000000..4ee942c --- /dev/null +++ b/java8-to-25/bridge/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + com.ankurm + bridge-classpath + 1.0 + pom + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.3 + + + org.glassfish.jaxb + jaxb-runtime + 2.3.9 + + + com.sun.xml.ws + jaxws-rt + 2.3.7 + + + jakarta.jws + jakarta.jws-api + 2.1.0 + + + org.openjdk.nashorn + nashorn-core + 15.7 + + + diff --git a/java8-to-25/fixed/pom.xml b/java8-to-25/fixed/pom.xml new file mode 100644 index 0000000..e562c90 --- /dev/null +++ b/java8-to-25/fixed/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + com.ankurm + fixed-app + 1.0 + + + 25 + UTF-8 + + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.5 + + + org.glassfish.jaxb + jaxb-runtime + 4.0.9 + runtime + + + + com.sun.xml.ws + jaxws-rt + 4.0.5 + + + + org.openjdk.nashorn + nashorn-core + 15.7 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.16.0 + + + + diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/App.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/App.java new file mode 100644 index 0000000..b21498b --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/App.java @@ -0,0 +1,29 @@ +package com.ankurm.fixed; + +import java.util.concurrent.Callable; + +/** Same steps as the legacy App, fixed for Java 25. */ +public final class App { + 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", () -> "list size=" + Peek.sized(32).size() + " (capacity no longer read)"); + step("securitymanager", Guard::runIsolated); + step("thread.stop", Watchdog::kill); + System.out.println(Report.lines()); + System.exit(0); + } + + private static void step(String name, Callable work) { + try { + System.out.println("[ok] " + name + ": " + work.call()); + } catch (Throwable t) { + System.out.println("[FAIL] " + name + ": " + t); + } + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Guard.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Guard.java new file mode 100644 index 0000000..e237ada --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Guard.java @@ -0,0 +1,22 @@ +package com.ankurm.fixed; + +import java.nio.file.Paths; + +/** + * There is no in-JVM replacement for the Security Manager. One option for untrusted or + * badly behaved code is a separate process: its exit cannot take the host down. + */ +public final class Guard { + 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"; + } + + public static final class Plugin { + public static void main(String[] args) { + System.exit(3); + } + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/JavaVersion.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/JavaVersion.java new file mode 100644 index 0000000..9d3ef7d --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/JavaVersion.java @@ -0,0 +1,8 @@ +package com.ankurm.fixed; + +/** Ask the runtime instead of parsing a string. Runtime.version() exists since Java 9. */ +public final class JavaVersion { + public static int major() { + return Runtime.version().feature(); + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Order.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Order.java new file mode 100644 index 0000000..96e596e --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Order.java @@ -0,0 +1,20 @@ +package com.ankurm.fixed; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlRootElement; + +/** Same bean; only the import prefix changed, javax.xml.bind to jakarta.xml.bind. */ +@XmlRootElement(name = "order") +@XmlAccessorType(XmlAccessType.FIELD) +public class Order { + public String id; + public int quantity; + + public Order() { } + + public Order(String id, int quantity) { + this.id = id; + this.quantity = quantity; + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/OrderXml.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/OrderXml.java new file mode 100644 index 0000000..d5fcf26 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/OrderXml.java @@ -0,0 +1,15 @@ +package com.ankurm.fixed; + +import java.io.StringWriter; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.Marshaller; + +public final class OrderXml { + public static String toXml(Order order) throws Exception { + Marshaller m = JAXBContext.newInstance(Order.class).createMarshaller(); + m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); + StringWriter out = new StringWriter(); + m.marshal(order, out); + return out.toString(); + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Peek.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Peek.java new file mode 100644 index 0000000..70c4940 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Peek.java @@ -0,0 +1,13 @@ +package com.ankurm.fixed; + +import java.util.ArrayList; + +/** + * There is no public API for an ArrayList's internal capacity, so the fix is to stop asking. + * If your code needs the number, it has to own it. + */ +public final class Peek { + public static ArrayList sized(int capacity) { + return new ArrayList<>(capacity); + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/PluginScanner.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/PluginScanner.java new file mode 100644 index 0000000..380c057 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/PluginScanner.java @@ -0,0 +1,11 @@ +package com.ankurm.fixed; + +import java.io.File; + +/** The class path is a system property; the loader's type is an implementation detail. */ +public final class PluginScanner { + public static int classpathEntries() { + String[] entries = System.getProperty("java.class.path").split(File.pathSeparator); + return entries.length > 0 ? 1 : 0; + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Report.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Report.java new file mode 100644 index 0000000..bb6be31 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Report.java @@ -0,0 +1,32 @@ +package com.ankurm.fixed; + +import java.nio.charset.StandardCharsets; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; + +/** Pin every format that another system reads. Do not rely on locale data staying put. */ +public final class Report { + public static String lines() { + LocalDateTime when = LocalDateTime.of(2026, 3, 5, 14, 30); + 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)); + return "date(en_US) = " + escape(us.format(when)) + "\n" + + "date(de_DE) = " + escape(de.format(when)) + "\n" + + "money(en_IN) = " + escape(inr.format(1234567.5)) + "\n" + + "charset used = " + StandardCharsets.UTF_8 + "\n" + + "rupee as bytes = " + "₹".getBytes(StandardCharsets.UTF_8).length + " byte(s)"; + } + + static String escape(String s) { + StringBuilder b = new StringBuilder(); + for (char ch : s.toCharArray()) { + if (ch < 127) b.append(ch); + else b.append(String.format("\\u%04X", (int) ch)); + } + return b.toString(); + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Rules.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Rules.java new file mode 100644 index 0000000..e315074 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Rules.java @@ -0,0 +1,13 @@ +package com.ankurm.fixed; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + +/** Unchanged code: the engine now comes from the nashorn-core dependency. */ +public final class Rules { + public static Object discount(int quantity) throws Exception { + ScriptEngine js = new ScriptEngineManager().getEngineByName("nashorn"); + js.put("quantity", quantity); + return js.eval("quantity > 10 ? 'BULK' : 'RETAIL'"); + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/SoapCheck.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/SoapCheck.java new file mode 100644 index 0000000..e752437 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/SoapCheck.java @@ -0,0 +1,19 @@ +package com.ankurm.fixed; + +import java.io.InputStream; +import java.net.URL; +import java.util.Scanner; +import jakarta.xml.ws.Endpoint; + +public final class SoapCheck { + public static String publishAndReadWsdl() throws Exception { + String address = "http://127.0.0.1:18099/status"; + Endpoint endpoint = Endpoint.publish(address, new StatusService()); + try (InputStream in = new URL(address + "?wsdl").openStream()) { + String wsdl = new Scanner(in, "UTF-8").useDelimiter("\\A").next(); + return wsdl.contains("name=\"StatusServiceService\"") ? "WSDL served" : "unexpected WSDL"; + } finally { + endpoint.stop(); + } + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/StatusService.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/StatusService.java new file mode 100644 index 0000000..8cbe89f --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/StatusService.java @@ -0,0 +1,13 @@ +package com.ankurm.fixed; + +import jakarta.jws.WebMethod; +import jakarta.jws.WebService; + +/** Same service; javax.jws became jakarta.jws. */ +@WebService +public class StatusService { + @WebMethod + public String status() { + return "UP"; + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Tokens.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Tokens.java new file mode 100644 index 0000000..1c074d4 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Tokens.java @@ -0,0 +1,10 @@ +package com.ankurm.fixed; + +import java.util.Base64; + +public final class Tokens { + /** getMimeEncoder() wraps at 76 characters like sun.misc did; getEncoder() does not wrap. */ + public static String encode(byte[] raw) { + return Base64.getMimeEncoder().encodeToString(raw); + } +} diff --git a/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Watchdog.java b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Watchdog.java new file mode 100644 index 0000000..2a0d773 --- /dev/null +++ b/java8-to-25/fixed/src/main/java/com/ankurm/fixed/Watchdog.java @@ -0,0 +1,22 @@ +package com.ankurm.fixed; + +/** Cooperative cancellation: interrupt, and the worker must honour the interrupt. */ +public final class Watchdog { + public static String kill() throws InterruptedException { + 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); + worker.start(); + Thread.sleep(100); + worker.interrupt(); + worker.join(1000); + return worker.isAlive() ? "still alive" : "stopped"; + } +} diff --git a/java8-to-25/flags/jdk8-flags.txt b/java8-to-25/flags/jdk8-flags.txt new file mode 100644 index 0000000..21c45ec --- /dev/null +++ b/java8-to-25/flags/jdk8-flags.txt @@ -0,0 +1,33 @@ +-XX:MaxPermSize=256m +-XX:PermSize=64m +-XX:+UseConcMarkSweepGC +-XX:+UseParNewGC +-XX:+CMSParallelRemarkEnabled +-XX:CMSInitiatingOccupancyFraction=70 +-XX:+UseParallelOldGC +-Xincgc +-XX:+PrintGCDetails +-XX:+PrintGCDateStamps +-XX:+PrintGCTimeStamps +-XX:+PrintTenuringDistribution +-XX:+PrintGCApplicationStoppedTime +-Xloggc:gc.log +-XX:+UseGCLogFileRotation +-XX:NumberOfGCLogFiles=5 +-XX:+AggressiveOpts +-XX:+UseBiasedLocking +-XX:+UseFastAccessorMethods +-XX:+AggressiveHeap +-XX:+UseCGroupMemoryLimitForHeap +-XX:+UseStringDeduplication +-XX:+DisableExplicitGC +-d64 +-Xverify:none +-Xfuture +--illegal-access=permit +-XX:+UnlockCommercialFeatures +-Djava.security.manager +-Djava.security.manager=allow +-Djava.endorsed.dirs=/tmp +-Djava.ext.dirs=/tmp +-Xbootclasspath/p:/tmp/none.jar diff --git a/java8-to-25/legacy/pom.xml b/java8-to-25/legacy/pom.xml new file mode 100644 index 0000000..d0fca21 --- /dev/null +++ b/java8-to-25/legacy/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.ankurm + legacy-app + 1.0 + + + 1.8 + 1.8 + UTF-8 + + diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/App.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/App.java new file mode 100644 index 0000000..a3469e8 --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/App.java @@ -0,0 +1,30 @@ +package com.ankurm.legacy; + +import java.util.ArrayList; +import java.util.concurrent.Callable; + +/** Runs every feature of the legacy app and keeps going after a failure. */ +public final class App { + 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 work) { + try { + System.out.println("[ok] " + name + ": " + work.call()); + } catch (Throwable t) { + System.out.println("[FAIL] " + name + ": " + t); + } + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Guard.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Guard.java new file mode 100644 index 0000000..57e021b --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Guard.java @@ -0,0 +1,21 @@ +package com.ankurm.legacy; + +/** Blocks System.exit from plugin code with a SecurityManager. */ +public final class Guard { + public static String install() { + System.setSecurityManager(new SecurityManager() { + @Override public void checkExit(int status) { + throw new SecurityException("plugins may not exit the JVM"); + } + @Override public void checkPermission(java.security.Permission p) { } + }); + try { + System.exit(3); + return "exited"; + } catch (SecurityException e) { + return "blocked: " + e.getMessage(); + } finally { + System.setSecurityManager(null); + } + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/JavaVersion.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/JavaVersion.java new file mode 100644 index 0000000..ac10151 --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/JavaVersion.java @@ -0,0 +1,9 @@ +package com.ankurm.legacy; + +/** The classic "which Java is this?" parser: assumes versions look like 1.x.y. */ +public final class JavaVersion { + public static int major() { + String v = System.getProperty("java.version"); + return Integer.parseInt(v.split("\\.")[1]); + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Order.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Order.java new file mode 100644 index 0000000..967efcd --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Order.java @@ -0,0 +1,20 @@ +package com.ankurm.legacy; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +/** A typical Java 8 era JAXB bean. javax.xml.bind shipped inside the JDK until Java 10. */ +@XmlRootElement(name = "order") +@XmlAccessorType(XmlAccessType.FIELD) +public class Order { + public String id; + public int quantity; + + public Order() { } + + public Order(String id, int quantity) { + this.id = id; + this.quantity = quantity; + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/OrderXml.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/OrderXml.java new file mode 100644 index 0000000..eea9fbe --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/OrderXml.java @@ -0,0 +1,15 @@ +package com.ankurm.legacy; + +import java.io.StringWriter; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +public final class OrderXml { + public static String toXml(Order order) throws Exception { + Marshaller m = JAXBContext.newInstance(Order.class).createMarshaller(); + m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); + StringWriter out = new StringWriter(); + m.marshal(order, out); + return out.toString(); + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Peek.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Peek.java new file mode 100644 index 0000000..35a9061 --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Peek.java @@ -0,0 +1,13 @@ +package com.ankurm.legacy; + +import java.lang.reflect.Field; +import java.util.ArrayList; + +/** Reads a private JDK field by reflection: the "illegal access" pattern. */ +public final class Peek { + public static int capacity(ArrayList list) throws Exception { + Field f = ArrayList.class.getDeclaredField("elementData"); + f.setAccessible(true); + return ((Object[]) f.get(list)).length; + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/PluginScanner.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/PluginScanner.java new file mode 100644 index 0000000..74eb96f --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/PluginScanner.java @@ -0,0 +1,12 @@ +package com.ankurm.legacy; + +import java.net.URL; +import java.net.URLClassLoader; + +/** Assumes the application class loader is a URLClassLoader. True up to Java 8 only. */ +public final class PluginScanner { + public static int classpathEntries() { + URL[] urls = ((URLClassLoader) ClassLoader.getSystemClassLoader()).getURLs(); + return urls.length > 0 ? 1 : 0; + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Report.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Report.java new file mode 100644 index 0000000..822000c --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Report.java @@ -0,0 +1,37 @@ +package com.ankurm.legacy; + +import java.nio.charset.Charset; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +/** Nothing here throws on any JDK. The text it prints is what changes. */ +public final class Report { + public static String lines() { + GregorianCalendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC"), Locale.US); + c.set(2026, Calendar.MARCH, 5, 14, 30, 0); + DateFormat us = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US); + us.setTimeZone(c.getTimeZone()); + DateFormat de = DateFormat.getDateInstance(DateFormat.FULL, Locale.GERMANY); + de.setTimeZone(c.getTimeZone()); + NumberFormat inr = NumberFormat.getCurrencyInstance(new Locale("en", "IN")); + return "date(en_US) = " + escape(us.format(c.getTime())) + "\n" + + "date(de_DE) = " + escape(de.format(c.getTime())) + "\n" + + "money(en_IN) = " + escape(inr.format(1234567.5)) + "\n" + + "defaultCharset = " + Charset.defaultCharset() + "\n" + + "rupee as bytes = " + "₹".getBytes().length + " byte(s)"; + } + + /** Print non-ASCII characters as \\uXXXX so the transcript shows invisible differences. */ + static String escape(String s) { + StringBuilder b = new StringBuilder(); + for (char ch : s.toCharArray()) { + if (ch < 127) b.append(ch); + else b.append(String.format("\\u%04X", (int) ch)); + } + return b.toString(); + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Rules.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Rules.java new file mode 100644 index 0000000..b22f05b --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Rules.java @@ -0,0 +1,13 @@ +package com.ankurm.legacy; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + +/** Business rules kept as JavaScript, run by Nashorn (removed in Java 15). */ +public final class Rules { + public static Object discount(int quantity) throws Exception { + ScriptEngine js = new ScriptEngineManager().getEngineByName("nashorn"); + js.put("quantity", quantity); + return js.eval("quantity > 10 ? 'BULK' : 'RETAIL'"); + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/SoapCheck.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/SoapCheck.java new file mode 100644 index 0000000..fa54391 --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/SoapCheck.java @@ -0,0 +1,19 @@ +package com.ankurm.legacy; + +import java.io.InputStream; +import java.net.URL; +import java.util.Scanner; +import javax.xml.ws.Endpoint; + +public final class SoapCheck { + public static String publishAndReadWsdl() throws Exception { + String address = "http://127.0.0.1:18099/status"; + Endpoint endpoint = Endpoint.publish(address, new StatusService()); + try (InputStream in = new URL(address + "?wsdl").openStream()) { + String wsdl = new Scanner(in, "UTF-8").useDelimiter("\\A").next(); + return wsdl.contains("name=\"StatusServiceService\"") ? "WSDL served" : "unexpected WSDL"; + } finally { + endpoint.stop(); + } + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/StatusService.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/StatusService.java new file mode 100644 index 0000000..dec213e --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/StatusService.java @@ -0,0 +1,13 @@ +package com.ankurm.legacy; + +import javax.jws.WebMethod; +import javax.jws.WebService; + +/** A JAX-WS (SOAP) service published with the JDK's built-in HTTP server. */ +@WebService +public class StatusService { + @WebMethod + public String status() { + return "UP"; + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Tokens.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Tokens.java new file mode 100644 index 0000000..aff0b93 --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Tokens.java @@ -0,0 +1,10 @@ +package com.ankurm.legacy; + +import sun.misc.BASE64Encoder; + +public final class Tokens { + /** sun.misc.BASE64Encoder was never a public API; it left the JDK in Java 9. */ + public static String encode(byte[] raw) { + return new BASE64Encoder().encode(raw); + } +} diff --git a/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Watchdog.java b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Watchdog.java new file mode 100644 index 0000000..d2875aa --- /dev/null +++ b/java8-to-25/legacy/src/main/java/com/ankurm/legacy/Watchdog.java @@ -0,0 +1,19 @@ +package com.ankurm.legacy; + +/** Kills a runaway worker with Thread.stop(), deprecated since Java 1.2. */ +public final class Watchdog { + @SuppressWarnings("deprecation") + public static String kill() throws InterruptedException { + Thread worker = new Thread(() -> { + while (true) { + try { Thread.sleep(50); } catch (InterruptedException ignored) { } + } + }); + worker.setDaemon(true); + worker.start(); + Thread.sleep(100); + worker.stop(); + worker.join(1000); + return worker.isAlive() ? "still alive" : "stopped"; + } +} diff --git a/java8-to-25/output/01-jdk8-compile-no-encoding.txt b/java8-to-25/output/01-jdk8-compile-no-encoding.txt new file mode 100644 index 0000000..82fb9be --- /dev/null +++ b/java8-to-25/output/01-jdk8-compile-no-encoding.txt @@ -0,0 +1,11 @@ +$ javac -version # JDK 8, no -encoding flag, LANG=C +src/main/java/com/ankurm/legacy/Report.java:25: error: unmappable character for encoding ASCII + + "rupee as bytes = " + "???".getBytes().length + " byte(s)"; + ^ +src/main/java/com/ankurm/legacy/Report.java:25: error: unmappable character for encoding ASCII + + "rupee as bytes = " + "???".getBytes().length + " byte(s)"; + ^ +src/main/java/com/ankurm/legacy/Report.java:25: error: unmappable character for encoding ASCII + + "rupee as bytes = " + "???".getBytes().length + " byte(s)"; + ^ +3 errors diff --git a/java8-to-25/output/02-run-on-jdk8.txt b/java8-to-25/output/02-run-on-jdk8.txt new file mode 100644 index 0000000..ed1881a --- /dev/null +++ b/java8-to-25/output/02-run-on-jdk8.txt @@ -0,0 +1,21 @@ +$ java -version +openjdk version "1.8.0_514" +OpenJDK Runtime Environment (Temurin)(build 1.8.0_514-b01) +OpenJDK 64-Bit Server VM (Temurin)(build 25.514-b01, mixed mode) + +$ java -cp classes-built-by-jdk8 com.ankurm.legacy.App +running on java.version 1.8.0_514 +[ok] jaxb: A-112 +[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\u00E4rz 2026 +money(en_IN) = Rs.1,234,567.50 +defaultCharset = US-ASCII +rupee as bytes = 1 byte(s) diff --git a/java8-to-25/output/03-jdk8-classes-on-jdk25.txt b/java8-to-25/output/03-jdk8-classes-on-jdk25.txt new file mode 100644 index 0000000..86112ba --- /dev/null +++ b/java8-to-25/output/03-jdk8-classes-on-jdk25.txt @@ -0,0 +1,21 @@ +$ java -version +openjdk version "25.0.5.1" 2026-11-17 LTS +OpenJDK Runtime Environment Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS) +OpenJDK 64-Bit Server VM Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing) + +$ java -cp classes-built-by-jdk8 com.ankurm.legacy.App +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 "" 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\u202FPM +date(de_DE) = Donnerstag, 5. M\u00E4rz 2026 +money(en_IN) = \u20B91,234,567.50 +defaultCharset = UTF-8 +rupee as bytes = 3 byte(s) diff --git a/java8-to-25/output/03b-jdk8-classes-on-jdk17.txt b/java8-to-25/output/03b-jdk8-classes-on-jdk17.txt new file mode 100644 index 0000000..8b31e31 --- /dev/null +++ b/java8-to-25/output/03b-jdk8-classes-on-jdk17.txt @@ -0,0 +1,20 @@ +$ java -cp classes-built-by-jdk8 com.ankurm.legacy.App # JDK 17, the middle of the staged path +running on java.version 17.0.21.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 "" 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 @7137feef +WARNING: A terminally deprecated method in java.lang.System has been called +WARNING: System::setSecurityManager has been called by com.ankurm.legacy.Guard (file:./build/c8/) +WARNING: Please consider reporting this to the maintainers of com.ankurm.legacy.Guard +WARNING: System::setSecurityManager will be removed in a future release +[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\u00E4rz 2026 +money(en_IN) = \u20B91,234,567.50 +defaultCharset = US-ASCII +rupee as bytes = 1 byte(s) diff --git a/java8-to-25/output/04-jdk25-compile.txt b/java8-to-25/output/04-jdk25-compile.txt new file mode 100644 index 0000000..9b6a431 --- /dev/null +++ b/java8-to-25/output/04-jdk25-compile.txt @@ -0,0 +1,97 @@ +$ javac -encoding UTF-8 ... # JDK 25 +src/main/java/com/ankurm/legacy/Order.java:3: error: package javax.xml.bind.annotation does not exist +import javax.xml.bind.annotation.XmlAccessType; + ^ +src/main/java/com/ankurm/legacy/Order.java:4: error: package javax.xml.bind.annotation does not exist +import javax.xml.bind.annotation.XmlAccessorType; + ^ +src/main/java/com/ankurm/legacy/Order.java:5: error: package javax.xml.bind.annotation does not exist +import javax.xml.bind.annotation.XmlRootElement; + ^ +src/main/java/com/ankurm/legacy/Order.java:8: error: cannot find symbol +@XmlRootElement(name = "order") + ^ + symbol: class XmlRootElement +src/main/java/com/ankurm/legacy/Order.java:9: error: cannot find symbol +@XmlAccessorType(XmlAccessType.FIELD) + ^ + symbol: class XmlAccessorType +src/main/java/com/ankurm/legacy/OrderXml.java:4: error: package javax.xml.bind does not exist +import javax.xml.bind.JAXBContext; + ^ +src/main/java/com/ankurm/legacy/OrderXml.java:5: error: package javax.xml.bind does not exist +import javax.xml.bind.Marshaller; + ^ +src/main/java/com/ankurm/legacy/SoapCheck.java:6: error: package javax.xml.ws does not exist +import javax.xml.ws.Endpoint; + ^ +src/main/java/com/ankurm/legacy/StatusService.java:3: error: package javax.jws does not exist +import javax.jws.WebMethod; + ^ +src/main/java/com/ankurm/legacy/StatusService.java:4: error: package javax.jws does not exist +import javax.jws.WebService; + ^ +src/main/java/com/ankurm/legacy/StatusService.java:7: error: cannot find symbol +@WebService + ^ + symbol: class WebService +src/main/java/com/ankurm/legacy/Tokens.java:3: error: cannot find symbol +import sun.misc.BASE64Encoder; + ^ + symbol: class BASE64Encoder + location: package sun.misc +src/main/java/com/ankurm/legacy/Order.java:9: error: cannot find symbol +@XmlAccessorType(XmlAccessType.FIELD) + ^ + symbol: variable XmlAccessType +src/main/java/com/ankurm/legacy/StatusService.java:9: error: cannot find symbol + @WebMethod + ^ + symbol: class WebMethod + location: class StatusService +src/main/java/com/ankurm/legacy/Guard.java:6: warning: [removal] SecurityManager in java.lang has been deprecated and marked for removal + System.setSecurityManager(new SecurityManager() { + ^ +src/main/java/com/ankurm/legacy/Guard.java:6: warning: [removal] setSecurityManager(SecurityManager) in System has been deprecated and marked for removal + System.setSecurityManager(new SecurityManager() { + ^ +src/main/java/com/ankurm/legacy/Guard.java:18: warning: [removal] setSecurityManager(SecurityManager) in System has been deprecated and marked for removal + System.setSecurityManager(null); + ^ +src/main/java/com/ankurm/legacy/OrderXml.java:9: error: cannot find symbol + Marshaller m = JAXBContext.newInstance(Order.class).createMarshaller(); + ^ + symbol: class Marshaller + location: class OrderXml +src/main/java/com/ankurm/legacy/OrderXml.java:9: error: cannot find symbol + Marshaller m = JAXBContext.newInstance(Order.class).createMarshaller(); + ^ + symbol: variable JAXBContext + location: class OrderXml +src/main/java/com/ankurm/legacy/OrderXml.java:10: error: cannot find symbol + m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); + ^ + symbol: variable Marshaller + location: class OrderXml +src/main/java/com/ankurm/legacy/SoapCheck.java:11: error: cannot find symbol + Endpoint endpoint = Endpoint.publish(address, new StatusService()); + ^ + symbol: class Endpoint + location: class SoapCheck +src/main/java/com/ankurm/legacy/SoapCheck.java:11: error: cannot find symbol + Endpoint endpoint = Endpoint.publish(address, new StatusService()); + ^ + symbol: variable Endpoint + location: class SoapCheck +src/main/java/com/ankurm/legacy/Tokens.java:8: error: cannot find symbol + return new BASE64Encoder().encode(raw); + ^ + symbol: class BASE64Encoder + location: class Tokens +src/main/java/com/ankurm/legacy/Watchdog.java:15: warning: [removal] stop() in Thread has been deprecated and marked for removal + worker.stop(); + ^ +Note: Some input files use or override a deprecated API. +Note: Recompile with -Xlint:deprecation for details. +20 errors +4 warnings diff --git a/java8-to-25/output/05-jdk25-release8.txt b/java8-to-25/output/05-jdk25-release8.txt new file mode 100644 index 0000000..60352f6 --- /dev/null +++ b/java8-to-25/output/05-jdk25-release8.txt @@ -0,0 +1,31 @@ +$ 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 + +$ 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 diff --git a/java8-to-25/output/06-jdeps-jdk-internals.txt b/java8-to-25/output/06-jdeps-jdk-internals.txt new file mode 100644 index 0000000..61876ba --- /dev/null +++ b/java8-to-25/output/06-jdeps-jdk-internals.txt @@ -0,0 +1,13 @@ +$ jdeps --jdk-internals legacy.jar +legacy.jar -> JDK removed internal API + com.ankurm.legacy.Tokens -> sun.misc.BASE64Encoder JDK removed internal API + +Warning: JDK internal APIs are unsupported and private to JDK implementation that are +subject to be removed or changed incompatibly and could break your application. +Please modify your code to eliminate dependence on any JDK internal APIs. +For the most recent update on JDK internal API replacements, please check: +https://wiki.openjdk.org/display/JDK8/Java+Dependency+Analysis+Tool + +JDK Internal API Suggested Replacement +---------------- --------------------- +sun.misc.BASE64Encoder Use java.util.Base64 @since 1.8 diff --git a/java8-to-25/output/07-jdeps-packages.txt b/java8-to-25/output/07-jdeps-packages.txt new file mode 100644 index 0000000..7109213 --- /dev/null +++ b/java8-to-25/output/07-jdeps-packages.txt @@ -0,0 +1,21 @@ +$ jdeps -verbose:package legacy.jar +legacy.jar -> JDK removed internal API +legacy.jar -> java.base +legacy.jar -> java.scripting +legacy.jar -> not found + com.ankurm.legacy -> java.io java.base + com.ankurm.legacy -> java.lang java.base + com.ankurm.legacy -> java.lang.invoke java.base + com.ankurm.legacy -> java.lang.reflect java.base + com.ankurm.legacy -> java.net java.base + com.ankurm.legacy -> java.nio.charset java.base + com.ankurm.legacy -> java.security java.base + com.ankurm.legacy -> java.text java.base + com.ankurm.legacy -> java.util java.base + com.ankurm.legacy -> java.util.concurrent java.base + com.ankurm.legacy -> javax.jws not found + com.ankurm.legacy -> javax.script java.scripting + com.ankurm.legacy -> javax.xml.bind not found + com.ankurm.legacy -> javax.xml.bind.annotation not found + com.ankurm.legacy -> javax.xml.ws not found + com.ankurm.legacy -> sun.misc JDK removed internal API diff --git a/java8-to-25/output/08-jdeprscan.txt b/java8-to-25/output/08-jdeprscan.txt new file mode 100644 index 0000000..4119ee1 --- /dev/null +++ b/java8-to-25/output/08-jdeprscan.txt @@ -0,0 +1,12 @@ +$ jdeprscan --release 25 legacy.jar +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::(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::(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) diff --git a/java8-to-25/output/09-jvm-flags.txt b/java8-to-25/output/09-jvm-flags.txt new file mode 100644 index 0000000..22aa2fb --- /dev/null +++ b/java8-to-25/output/09-jvm-flags.txt @@ -0,0 +1,334 @@ +################ -XX:MaxPermSize=256m +JDK 8 exit=0 + OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 +JDK 17 exit=1 + Unrecognized VM option 'MaxPermSize=256m' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'MaxPermSize=256m' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:PermSize=64m +JDK 8 exit=0 + OpenJDK 64-Bit Server VM warning: ignoring option PermSize=64m; support was removed in 8.0 +JDK 17 exit=1 + Unrecognized VM option 'PermSize=64m' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'PermSize=64m' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -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' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+UseParNewGC +JDK 8 exit=0 + OpenJDK 64-Bit Server VM warning: Using the ParNew young collector with the Serial old collector is deprecated and will likely be removed in a future release +JDK 17 exit=1 + Unrecognized VM option 'UseParNewGC' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'UseParNewGC' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+CMSParallelRemarkEnabled +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'CMSParallelRemarkEnabled' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'CMSParallelRemarkEnabled' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:CMSInitiatingOccupancyFraction=70 +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'CMSInitiatingOccupancyFraction=70' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'CMSInitiatingOccupancyFraction=70' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+UseParallelOldGC +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'UseParallelOldGC' + Did you mean '(+/-)UseParallelGC'? Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'UseParallelOldGC' + Did you mean '(+/-)UseParallelGC'? + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -Xincgc +JDK 8 exit=0 + OpenJDK 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release +JDK 17 exit=1 + Unrecognized option: -Xincgc + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized option: -Xincgc + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+PrintGCDetails +JDK 8 exit=0 + Heap + PSYoungGen total 28672K, used 983K [0x00000000e0000000, 0x00000000e2000000, 0x0000000100000000) + eden space 24576K, 4% used [0x00000000e0000000,0x00000000e00f5da8,0x00000000e1800000) + from space 4096K, 0% used [0x00000000e1c00000,0x00000000e1c00000,0x00000000e2000000) +JDK 17 exit=0 + [0.0NNs][warning][gc] -XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead. + [0.0NNs][info ][gc] Using G1 + [0.0NNs][info ][gc,init] Version: 17.0.21.1+2 (release) + [0.0NNs][info ][gc,init] CPUs: 2 total, 2 available +JDK 25 exit=0 + [0.0NNs][warning][gc] -XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead. + [0.0NNs][info ][gc,init] CardTable entry size: 512 + [0.0NNs][info ][gc ] Using G1 + [0.0NNs][info ][gc,init] Version: 25.0.5.1+2-LTS (release) +################ -XX:+PrintGCDateStamps +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'PrintGCDateStamps' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'PrintGCDateStamps' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+PrintGCTimeStamps +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'PrintGCTimeStamps' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'PrintGCTimeStamps' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+PrintTenuringDistribution +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'PrintTenuringDistribution' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'PrintTenuringDistribution' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+PrintGCApplicationStoppedTime +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'PrintGCApplicationStoppedTime' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'PrintGCApplicationStoppedTime' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -Xloggc:gc.log +JDK 8 exit=0 +JDK 17 exit=0 + [0.0NNs][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:gc.log instead. + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=0 + [0.0NNs][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:gc.log instead. + OpenJDK 64-Bit Server VM Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing) +################ -XX:+UseGCLogFileRotation +JDK 8 exit=0 + To enable GC log rotation, use -Xloggc: -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles= + where num_of_file > 0 + GC log rotation is turned off +JDK 17 exit=1 + Unrecognized VM option 'UseGCLogFileRotation' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'UseGCLogFileRotation' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:NumberOfGCLogFiles=5 +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'NumberOfGCLogFiles=5' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'NumberOfGCLogFiles=5' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+AggressiveOpts +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'AggressiveOpts' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'AggressiveOpts' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+UseBiasedLocking +JDK 8 exit=0 +JDK 17 exit=0 + OpenJDK 64-Bit Server VM warning: Option UseBiasedLocking was deprecated in version 15.0 and will likely be removed in a future release. + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=1 + Unrecognized VM option 'UseBiasedLocking' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+UseFastAccessorMethods +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'UseFastAccessorMethods' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'UseFastAccessorMethods' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+AggressiveHeap +JDK 8 exit=0 +JDK 17 exit=0 + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=0 + OpenJDK 64-Bit Server VM Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing) +################ -XX:+UseCGroupMemoryLimitForHeap +JDK 8 exit=1 + Error: VM option 'UseCGroupMemoryLimitForHeap' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions. + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 17 exit=1 + Unrecognized VM option 'UseCGroupMemoryLimitForHeap' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'UseCGroupMemoryLimitForHeap' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -XX:+UseStringDeduplication +JDK 8 exit=0 +JDK 17 exit=0 + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=0 + OpenJDK 64-Bit Server VM Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing) +################ -XX:+DisableExplicitGC +JDK 8 exit=0 +JDK 17 exit=0 + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=0 + OpenJDK 64-Bit Server VM Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing) +################ -d64 +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized option: -d64 + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized option: -d64 + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -Xverify:none +JDK 8 exit=0 +JDK 17 exit=0 + OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=0 + OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. + OpenJDK 64-Bit Server VM Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing) +################ -Xfuture +JDK 8 exit=0 +JDK 17 exit=0 + Warning: -Xfuture option is deprecated and may be removed in a future release. + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode) +JDK 25 exit=1 + Unrecognized option: -Xfuture + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ --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) +JDK 25 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-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing) +################ -XX:+UnlockCommercialFeatures +JDK 8 exit=0 +JDK 17 exit=1 + Unrecognized VM option 'UnlockCommercialFeatures' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + Unrecognized VM option 'UnlockCommercialFeatures' + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -Djava.security.manager +JDK 8 exit=0 +JDK 17 exit=0 + WARNING: A command line option has enabled the Security Manager + WARNING: The Security Manager is deprecated and will be removed in a future release + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=1 + Error occurred during initialization of VM + java.lang.Error: A command line option has attempted to allow or enable the Security Manager. Enabling a Security Manager is not supported. + at java.lang.System.initPhase3(java.base@25.0.5.1/System.java:1970) +################ -Djava.security.manager=allow +JDK 8 exit=1 + Error occurred during initialization of VM + java.lang.InternalError: Could not create SecurityManager: allow + at sun.misc.Launcher.(Launcher.java:106) + at sun.misc.Launcher.(Launcher.java:54) +JDK 17 exit=0 + OpenJDK 64-Bit Server VM Temurin-17.0.21.1+2 (build 17.0.21.1+2, mixed mode, sharing) +JDK 25 exit=1 + Error occurred during initialization of VM + java.lang.Error: A command line option has attempted to allow or enable the Security Manager. Enabling a Security Manager is not supported. + at java.lang.System.initPhase3(java.base@25.0.5.1/System.java:1970) +################ -Djava.endorsed.dirs=/tmp +JDK 8 exit=0 +JDK 17 exit=1 + -Djava.endorsed.dirs=/tmp is not supported. Endorsed standards and standalone APIs + in modular form will be supported via the concept of upgradeable modules. + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + -Djava.endorsed.dirs=/tmp is not supported. Endorsed standards and standalone APIs + in modular form will be supported via the concept of upgradeable modules. + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -Djava.ext.dirs=/tmp +JDK 8 exit=0 +JDK 17 exit=1 + -Djava.ext.dirs=/tmp is not supported. Use -classpath instead. + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + -Djava.ext.dirs=/tmp is not supported. Use -classpath instead. + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +################ -Xbootclasspath/p:/tmp/none.jar +JDK 8 exit=0 +JDK 17 exit=1 + -Xbootclasspath/p is no longer a supported option. + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. +JDK 25 exit=1 + -Xbootclasspath/p is no longer a supported option. + Error: Could not create the Java Virtual Machine. + Error: A fatal exception has occurred. Program will exit. diff --git a/java8-to-25/output/10-gc-defaults.txt b/java8-to-25/output/10-gc-defaults.txt new file mode 100644 index 0000000..1dd7197 --- /dev/null +++ b/java8-to-25/output/10-gc-defaults.txt @@ -0,0 +1,53 @@ +################ JDK 8, -XX:ActiveProcessorCount=2 + MaxHeapSize 1610612736 + UseCompressedOops true + UseContainerSupport true + UseG1GC false + UseParallelGC true + UseSerialGC false + UseStringDeduplication false +################ JDK 8, -XX:ActiveProcessorCount=1 + MaxHeapSize 1610612736 + UseCompressedOops true + UseContainerSupport true + UseG1GC false + UseParallelGC false + UseSerialGC false + UseStringDeduplication false +################ JDK 17, -XX:ActiveProcessorCount=2 + MaxHeapSize 1610612736 + UseCompressedOops true + UseContainerSupport true + UseG1GC true + UseParallelGC false + UseSerialGC false + UseStringDeduplication false +################ JDK 17, -XX:ActiveProcessorCount=1 + MaxHeapSize 1610612736 + UseCompressedOops true + UseContainerSupport true + UseG1GC false + UseParallelGC false + UseSerialGC true + UseStringDeduplication false +################ JDK 25, -XX:ActiveProcessorCount=2 + MaxHeapSize 1610612736 + UseCompactObjectHeaders false + UseCompressedOops true + UseContainerSupport true + UseG1GC true + UseParallelGC false + UseSerialGC false + UseStringDeduplication false +################ JDK 25, -XX:ActiveProcessorCount=1 + MaxHeapSize 1610612736 + UseCompactObjectHeaders false + UseCompressedOops true + UseContainerSupport true + UseG1GC false + UseParallelGC false + UseSerialGC true + UseStringDeduplication false +################ JDK 8 with 1 CPU: no UseXxxGC flag is set, so ask for the heap layout + def new generation + tenured generation diff --git a/java8-to-25/output/11-tls-crypto-defaults.txt b/java8-to-25/output/11-tls-crypto-defaults.txt new file mode 100644 index 0000000..8e6013e --- /dev/null +++ b/java8-to-25/output/11-tls-crypto-defaults.txt @@ -0,0 +1,93 @@ +################ JDK 8 +java.version = 1.8.0_514 +keystore.type = jks +protocols = [TLSv1.3, TLSv1.2] +cipher suites = 33 enabled, 6 of them TLS_RSA_* +jdk.tls.disabledAlgorithms = + SSLv3 + TLSv1 + TLSv1.1 + RC4 + DES + MD5withRSA + DH keySize < 1024 + EC keySize < 224 + 3DES_EDE_CBC + anon + NULL + ECDH + include jdk.disabled.namedCurves +jdk.jar.disabledAlgorithms = + MD2 + MD5 + RSA keySize < 1024 + DSA keySize < 1024 + SHA1 denyAfter 2019-01-01 + include jdk.disabled.namedCurves +[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) +[ok] TLS_RSA_WITH_AES_128_GCM_SHA256 -> TLSv1.2 TLS_RSA_WITH_AES_128_GCM_SHA256 +################ JDK 17 +java.version = 17.0.21.1 +keystore.type = pkcs12 +protocols = [TLSv1.3, TLSv1.2] +cipher suites = 31 enabled, 0 of them TLS_RSA_* +jdk.tls.disabledAlgorithms = + SSLv3 + TLSv1 + TLSv1.1 + DTLSv1.0 + RC4 + DES + MD5withRSA + DH keySize < 1024 + EC keySize < 224 + 3DES_EDE_CBC + anon + NULL + ECDH + TLS_RSA_* + rsa_pkcs1_sha1 usage HandshakeSignature + ecdsa_sha1 usage HandshakeSignature + dsa_sha1 usage HandshakeSignature +jdk.jar.disabledAlgorithms = + MD2 + MD5 + RSA keySize < 1024 + DSA keySize < 1024 + SHA1 denyAfter 2019-01-01 +[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) +################ JDK 25 +java.version = 25.0.5.1 +keystore.type = pkcs12 +protocols = [TLSv1.3, TLSv1.2] +cipher suites = 31 enabled, 0 of them TLS_RSA_* +jdk.tls.disabledAlgorithms = + SSLv3 + TLSv1 + TLSv1.1 + DTLSv1.0 + RC4 + DES + MD5withRSA + DH keySize < 1024 + EC keySize < 224 + 3DES_EDE_CBC + anon + NULL + ECDH + TLS_RSA_* + rsa_pkcs1_sha1 usage HandshakeSignature + ecdsa_sha1 usage HandshakeSignature + dsa_sha1 usage HandshakeSignature +jdk.jar.disabledAlgorithms = + MD2 + MD5 + RSA keySize < 1024 + DSA keySize < 1024 + SHA1 denyAfter 2019-01-01 +[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) diff --git a/java8-to-25/output/12-sha1-signed-jar.txt b/java8-to-25/output/12-sha1-signed-jar.txt new file mode 100644 index 0000000..d58ab58 --- /dev/null +++ b/java8-to-25/output/12-sha1-signed-jar.txt @@ -0,0 +1,10 @@ +################ JDK 8: jarsigner -verify signed.jar + +The jar will be treated as unsigned, because it is signed with a weak algorithm that is now disabled. + +Re-run jarsigner with the -verbose option for more details. +################ JDK 25: jarsigner -verify signed.jar + +The jar will be treated as unsigned, because it is signed with a weak algorithm that is now disabled. + +Re-run jarsigner with the -verbose option for more details. diff --git a/java8-to-25/output/13-bridge-on-jdk25.txt b/java8-to-25/output/13-bridge-on-jdk25.txt new file mode 100644 index 0000000..2f817cc --- /dev/null +++ b/java8-to-25/output/13-bridge-on-jdk25.txt @@ -0,0 +1,25 @@ +$ 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 +running on java.version 25.0.5.1 +[ok] jaxb: A-112 +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:./bridge/target/dependency/jaxws-rt-2.3.7.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 +Dec 03, 2026 11:43:45 PM sun.util.locale.provider.LocaleProviderAdapter +INFO: Invalid locale provider adapter "COMPAT" ignored. +Dec 03, 2026 11:43:45 PM sun.util.locale.provider.LocaleProviderAdapter +WARNING: COMPAT locale provider has been removed +[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 +date(en_US) = Mar 5, 2026, 2:30\u202FPM +date(de_DE) = Donnerstag, 5. M\u00E4rz 2026 +money(en_IN) = \u20B91,234,567.50 +defaultCharset = US-ASCII +rupee as bytes = 1 byte(s) diff --git a/java8-to-25/output/14-fixed-on-jdk25.txt b/java8-to-25/output/14-fixed-on-jdk25.txt new file mode 100644 index 0000000..5a9c932 --- /dev/null +++ b/java8-to-25/output/14-fixed-on-jdk25.txt @@ -0,0 +1,22 @@ +$ java -cp target/classes:target/dependency/* com.ankurm.fixed.App # JDK 25 +running on java.version 25.0.5.1 +[ok] jaxb: A-112 +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 + 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\u00E4rz 2026 +money(en_IN) = Rs.1,234,567.50 +charset used = UTF-8 +rupee as bytes = 3 byte(s) diff --git a/java8-to-25/output/15-openrewrite-diff.txt b/java8-to-25/output/15-openrewrite-diff.txt new file mode 100644 index 0000000..b686a4a --- /dev/null +++ b/java8-to-25/output/15-openrewrite-diff.txt @@ -0,0 +1,131 @@ + pom.xml | 33 +++++++++++++++++++++++++-- + src/main/java/com/ankurm/legacy/App.java | 8 +++---- + src/main/java/com/ankurm/legacy/Report.java | 2 +- + src/main/java/com/ankurm/legacy/Tokens.java | 4 ++-- + src/main/java/com/ankurm/legacy/Watchdog.java | 7 +++++- + 5 files changed, 44 insertions(+), 10 deletions(-) + +diff --git a/pom.xml b/pom.xml +index d0fca21..3fae6a0 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -8,8 +8,37 @@ + 1.0 + + +- 1.8 +- 1.8 ++ 25 ++ 25 + UTF-8 + ++ ++ ++ jakarta.jws ++ jakarta.jws-api ++ 2.1.0 ++ ++ ++ jakarta.xml.bind ++ jakarta.xml.bind-api ++ 2.3.3 ++ ++ ++ jakarta.xml.ws ++ jakarta.xml.ws-api ++ 2.3.3 ++ ++ ++ com.sun.xml.ws ++ jaxws-rt ++ 2.3.7 ++ provided ++ ++ ++ org.glassfish.jaxb ++ jaxb-runtime ++ 2.3.9 ++ runtime ++ ++ + +diff --git a/src/main/java/com/ankurm/legacy/App.java b/src/main/java/com/ankurm/legacy/App.java +index a3469e8..308457a 100644 +--- a/src/main/java/com/ankurm/legacy/App.java ++++ b/src/main/java/com/ankurm/legacy/App.java +@@ -6,7 +6,7 @@ import java.util.concurrent.Callable; + /** Runs every feature of the legacy app and keeps going after a failure. */ + public final class App { + public static void main(String[] args) { +- System.out.println("running on java.version " + System.getProperty("java.version")); ++ IO.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"))); +@@ -16,15 +16,15 @@ public final class App { + step("reflection", () -> "ArrayList capacity=" + Peek.capacity(new ArrayList<>(32))); + step("securitymanager", Guard::install); + step("thread.stop", Watchdog::kill); +- System.out.println(Report.lines()); ++ IO.println(Report.lines()); + System.exit(0); + } + + private static void step(String name, Callable work) { + try { +- System.out.println("[ok] " + name + ": " + work.call()); ++ IO.println("[ok] " + name + ": " + work.call()); + } catch (Throwable t) { +- System.out.println("[FAIL] " + name + ": " + t); ++ IO.println("[FAIL] " + name + ": " + t); + } + } + } +diff --git a/src/main/java/com/ankurm/legacy/Report.java b/src/main/java/com/ankurm/legacy/Report.java +index 822000c..59a8485 100644 +--- a/src/main/java/com/ankurm/legacy/Report.java ++++ b/src/main/java/com/ankurm/legacy/Report.java +@@ -17,7 +17,7 @@ public final class Report { + us.setTimeZone(c.getTimeZone()); + DateFormat de = DateFormat.getDateInstance(DateFormat.FULL, Locale.GERMANY); + de.setTimeZone(c.getTimeZone()); +- NumberFormat inr = NumberFormat.getCurrencyInstance(new Locale("en", "IN")); ++ NumberFormat inr = NumberFormat.getCurrencyInstance(Locale.of("en", "IN")); + return "date(en_US) = " + escape(us.format(c.getTime())) + "\n" + + "date(de_DE) = " + escape(de.format(c.getTime())) + "\n" + + "money(en_IN) = " + escape(inr.format(1234567.5)) + "\n" +diff --git a/src/main/java/com/ankurm/legacy/Tokens.java b/src/main/java/com/ankurm/legacy/Tokens.java +index aff0b93..a78409d 100644 +--- a/src/main/java/com/ankurm/legacy/Tokens.java ++++ b/src/main/java/com/ankurm/legacy/Tokens.java +@@ -1,10 +1,10 @@ + package com.ankurm.legacy; + +-import sun.misc.BASE64Encoder; ++import java.util.Base64; + + public final class Tokens { + /** sun.misc.BASE64Encoder was never a public API; it left the JDK in Java 9. */ + public static String encode(byte[] raw) { +- return new BASE64Encoder().encode(raw); ++ return Base64.getEncoder().encodeToString(raw); + } + } +diff --git a/src/main/java/com/ankurm/legacy/Watchdog.java b/src/main/java/com/ankurm/legacy/Watchdog.java +index d2875aa..df39ab8 100644 +--- a/src/main/java/com/ankurm/legacy/Watchdog.java ++++ b/src/main/java/com/ankurm/legacy/Watchdog.java +@@ -12,7 +12,12 @@ public final class Watchdog { + worker.setDaemon(true); + worker.start(); + Thread.sleep(100); +- 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(); + worker.join(1000); + return worker.isAlive() ? "still alive" : "stopped"; + } diff --git a/java8-to-25/output/16-openrewrite-build.txt b/java8-to-25/output/16-openrewrite-build.txt new file mode 100644 index 0000000..82734b2 --- /dev/null +++ b/java8-to-25/output/16-openrewrite-build.txt @@ -0,0 +1,4 @@ +$ 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 +[ERROR] src/main/java/com/ankurm/legacy/Watchdog.java:[21,9] unreachable statement diff --git a/java8-to-25/output/17-openrewrite-run.txt b/java8-to-25/output/17-openrewrite-run.txt new file mode 100644 index 0000000..defae95 --- /dev/null +++ b/java8-to-25/output/17-openrewrite-run.txt @@ -0,0 +1,16 @@ +$ java ... # JDK 25, recipe output plus the one hand edit, runtime classpath +running on java.version 25.0.5.1 +[ok] jaxb: A-112 +[FAIL] jaxws: javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found +[ok] base64: YW5rdXI= +[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 +date(en_US) = Mar 5, 2026, 2:30\u202FPM +date(de_DE) = Donnerstag, 5. M\u00E4rz 2026 +money(en_IN) = \u20B91,234,567.50 +defaultCharset = UTF-8 +rupee as bytes = 3 byte(s) diff --git a/java8-to-25/output/18-lombok.txt b/java8-to-25/output/18-lombok.txt new file mode 100644 index 0000000..99bacca --- /dev/null +++ b/java8-to-25/output/18-lombok.txt @@ -0,0 +1,20 @@ +################ 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 +################ lombok 1.18.36 with -processorpath +An annotation processor threw an uncaught exception. +Caused by: java.lang.NoSuchFieldException: com.sun.tools.javac.code.TypeTag :: UNKNOWN +################ lombok 1.18.38 with -processorpath +getter says ankur +################ lombok 1.18.40 with -processorpath +getter says ankur +################ lombok 1.18.48 with -processorpath +getter says ankur +################ 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 +1 error diff --git a/java8-to-25/output/19-mockito.txt b/java8-to-25/output/19-mockito.txt new file mode 100644 index 0000000..f395d80 --- /dev/null +++ b/java8-to-25/output/19-mockito.txt @@ -0,0 +1,9 @@ +################ mockito-core 2.28.2 (byte-buddy 1.9.10) +mocked price 42 +################ mockito-core 4.11.0 (byte-buddy 1.12.19) +mocked price 42 +################ 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 +################ mockito-core 5.25.0 (byte-buddy 1.18.17) +mocked price 42 diff --git a/java8-to-25/output/20-asm.txt b/java8-to-25/output/20-asm.txt new file mode 100644 index 0000000..e2b3cf1 --- /dev/null +++ b/java8-to-25/output/20-asm.txt @@ -0,0 +1,8 @@ +################ asm 9.2 +Exception in thread "main" java.lang.IllegalArgumentException: Unsupported class file major version 69 +################ asm 9.7.1 +Exception in thread "main" java.lang.IllegalArgumentException: Unsupported class file major version 69 +################ asm 9.8 +parsed AsmRead +################ asm 9.11.1 +parsed AsmRead diff --git a/java8-to-25/output/21-jacoco.txt b/java8-to-25/output/21-jacoco.txt new file mode 100644 index 0000000..278f081 --- /dev/null +++ b/java8-to-25/output/21-jacoco.txt @@ -0,0 +1,9 @@ +################ jacoco agent 0.8.11 +Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 69 +hello from a Java 25 class +################ jacoco agent 0.8.13 +hello from a Java 25 class +################ jacoco agent 0.8.14 +hello from a Java 25 class +################ jacoco agent 0.8.16 +hello from a Java 25 class diff --git a/java8-to-25/output/22-boot27.txt b/java8-to-25/output/22-boot27.txt new file mode 100644 index 0000000..4cf575f --- /dev/null +++ b/java8-to-25/output/22-boot27.txt @@ -0,0 +1,6 @@ +################ Spring Boot 2.7.18 on JDK 25, application compiled with --release 8 +context started +################ Spring Boot 2.7.18 on JDK 25, application compiled with --release 25 +2026-12-03 23:44:39.780 WARN 22340 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to rea +org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [./build/libs/bt/app/DemoApp.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - pro +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 diff --git a/java8-to-25/output/23-maven-old-levels.txt b/java8-to-25/output/23-maven-old-levels.txt new file mode 100644 index 0000000..7420479 --- /dev/null +++ b/java8-to-25/output/23-maven-old-levels.txt @@ -0,0 +1,11 @@ +################ 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 +[ERROR] Source option 7 is no longer supported. Use 8 or later. +[ERROR] Target option 7 is no longer supported. Use 8 or later. +################ maven.compiler.source/target=1.8, JDK 25 +[WARNING] source value 8 is obsolete and will be removed in a future release +[WARNING] target value 8 is obsolete and will be removed in a future release +[WARNING] To suppress warnings about obsolete options, use -Xlint:-options. +[INFO] BUILD SUCCESS diff --git a/java8-to-25/output/24-gradle-on-25.txt b/java8-to-25/output/24-gradle-on-25.txt new file mode 100644 index 0000000..1b661a3 --- /dev/null +++ b/java8-to-25/output/24-gradle-on-25.txt @@ -0,0 +1,12 @@ +$ gradle compileJava # Gradle 8.14.3, JAVA_HOME = JDK 25 +exit status: 1 +FAILURE: Build failed with an exception. +* What went wrong: +BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 69 +> Unsupported class file major version 69 +* Try: +> Run with --stacktrace option to get the stack trace. +> Run with --info or --debug option to get more log output. +> Run with --scan to get full insights. +> Get more help at https://help.gradle.org. +BUILD FAILED in 4s diff --git a/java8-to-25/output/25-javax-packages.txt b/java8-to-25/output/25-javax-packages.txt new file mode 100644 index 0000000..7ed41e7 --- /dev/null +++ b/java8-to-25/output/25-javax-packages.txt @@ -0,0 +1,21 @@ +$ java JavaxMap.java # JDK 25 +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 diff --git a/java8-to-25/output/26-mixed-namespaces.txt b/java8-to-25/output/26-mixed-namespaces.txt new file mode 100644 index 0000000..117182d --- /dev/null +++ b/java8-to-25/output/26-mixed-namespaces.txt @@ -0,0 +1,6 @@ +$ java Mixed # javax annotations on the bean, jakarta JAXB runtime +Exception in thread "main" jakarta.xml.bind.MarshalException + - with linked exception: +[com.sun.istack.SAXException2: unable to marshal type "Mixed$Order" as an element because it is missing an @XmlRootElement annotation] +Caused by: com.sun.istack.SAXException2: unable to marshal type "Mixed$Order" as an element because it is missing an @XmlRootElement annotation + ... 3 more diff --git a/java8-to-25/output/27-bridge-jars-on-jdk8.txt b/java8-to-25/output/27-bridge-jars-on-jdk8.txt new file mode 100644 index 0000000..f990eac --- /dev/null +++ b/java8-to-25/output/27-bridge-jars-on-jdk8.txt @@ -0,0 +1,16 @@ +$ java -cp classes-built-by-jdk8:bridge-jars-without-nashorn com.ankurm.legacy.App # JDK 8 +running on java.version 1.8.0_514 +[ok] jaxb: A-112 +[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\u00E4rz 2026 +money(en_IN) = Rs.1,234,567.50 +defaultCharset = US-ASCII +rupee as bytes = 1 byte(s) diff --git a/java8-to-25/probes/javax/JavaxMap.java b/java8-to-25/probes/javax/JavaxMap.java new file mode 100644 index 0000000..98845f5 --- /dev/null +++ b/java8-to-25/probes/javax/JavaxMap.java @@ -0,0 +1,20 @@ +import java.util.ArrayList; +import java.util.List; + +/** Which javax.* packages does this JDK still contain, and which Java EE ones are gone? */ +public class JavaxMap { + public static void main(String[] args) { + List inJdk = new ArrayList<>(); + ModuleLayer.boot().modules().forEach(m -> m.getPackages().stream() + .filter(p -> p.startsWith("javax.") && m.getDescriptor().exports().stream() + .anyMatch(e -> e.source().equals(p) && !e.isQualified())) + .forEach(inJdk::add)); + System.out.println("exported javax.* packages in this JDK: " + inJdk.size()); + for (String p : new String[] {"javax.sql", "javax.crypto", "javax.net.ssl", "javax.naming", + "javax.management", "javax.script", "javax.swing", "javax.xml.parsers", "javax.transaction.xa", + "javax.annotation.processing", "javax.xml.bind", "javax.xml.ws", "javax.jws", "javax.activation", + "javax.annotation", "javax.transaction", "javax.servlet", "javax.persistence", "javax.validation"}) { + System.out.printf(" %-28s %s%n", p, inJdk.contains(p) ? "in the JDK, keep javax" : "not in the JDK"); + } + } +} diff --git a/java8-to-25/probes/libs/AsmRead.java b/java8-to-25/probes/libs/AsmRead.java new file mode 100644 index 0000000..59663e2 --- /dev/null +++ b/java8-to-25/probes/libs/AsmRead.java @@ -0,0 +1,9 @@ +import org.objectweb.asm.ClassReader; + +/** Reads its own class file, which javac 25 writes as major version 69. */ +public class AsmRead { + public static void main(String[] args) throws Exception { + ClassReader r = new ClassReader(AsmRead.class.getResourceAsStream("AsmRead.class")); + System.out.println("parsed " + r.getClassName()); + } +} diff --git a/java8-to-25/probes/libs/Hello.java b/java8-to-25/probes/libs/Hello.java new file mode 100644 index 0000000..bd1c57e --- /dev/null +++ b/java8-to-25/probes/libs/Hello.java @@ -0,0 +1,5 @@ +public class Hello { + public static void main(String[] args) { + System.out.println("hello from a Java 25 class"); + } +} diff --git a/java8-to-25/probes/libs/LombokBean.java b/java8-to-25/probes/libs/LombokBean.java new file mode 100644 index 0000000..2c63b4c --- /dev/null +++ b/java8-to-25/probes/libs/LombokBean.java @@ -0,0 +1,9 @@ +@lombok.Getter +@lombok.AllArgsConstructor +public class LombokBean { + private final String name; + + public static void main(String[] args) { + System.out.println("getter says " + new LombokBean("ankur").getName()); + } +} diff --git a/java8-to-25/probes/libs/MockDemo.java b/java8-to-25/probes/libs/MockDemo.java new file mode 100644 index 0000000..c9711c8 --- /dev/null +++ b/java8-to-25/probes/libs/MockDemo.java @@ -0,0 +1,14 @@ +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class MockDemo { + public static class PriceService { + public int price() { return 100; } + } + + public static void main(String[] args) { + PriceService s = mock(PriceService.class); + when(s.price()).thenReturn(42); + System.out.println("mocked price " + s.price()); + } +} diff --git a/java8-to-25/probes/libs/boot27/app/DemoApp.java b/java8-to-25/probes/libs/boot27/app/DemoApp.java new file mode 100644 index 0000000..ecdb186 --- /dev/null +++ b/java8-to-25/probes/libs/boot27/app/DemoApp.java @@ -0,0 +1,13 @@ +package app; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** A minimal Spring Boot 2.7 (javax era) app: component scanning reads class files with ASM. */ +@SpringBootApplication +public class DemoApp { + public static void main(String[] args) { + SpringApplication.run(DemoApp.class, args).close(); + System.out.println("context started"); + } +} diff --git a/java8-to-25/probes/libs/boot27/app/Greeter.java b/java8-to-25/probes/libs/boot27/app/Greeter.java new file mode 100644 index 0000000..6078e7c --- /dev/null +++ b/java8-to-25/probes/libs/boot27/app/Greeter.java @@ -0,0 +1,6 @@ +package app; + +import org.springframework.stereotype.Component; + +@Component +public class Greeter { } diff --git a/java8-to-25/probes/libs/boot27/pom.xml b/java8-to-25/probes/libs/boot27/pom.xml new file mode 100644 index 0000000..b363541 --- /dev/null +++ b/java8-to-25/probes/libs/boot27/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + com.ankurm + boot27-classpath + 1.0 + pom + + + org.springframework.boot + spring-boot-starter + 2.7.18 + + + diff --git a/java8-to-25/probes/mixed/pom.xml b/java8-to-25/probes/mixed/pom.xml new file mode 100644 index 0000000..cdb5104 --- /dev/null +++ b/java8-to-25/probes/mixed/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + com.ankurm + mixed-namespaces + 1.0 + + 25 + UTF-8 + + + + + javax.xml.bind + jaxb-api + 2.3.1 + + + + org.glassfish.jaxb + jaxb-runtime + 4.0.9 + + + diff --git a/java8-to-25/probes/mixed/src/main/java/Mixed.java b/java8-to-25/probes/mixed/src/main/java/Mixed.java new file mode 100644 index 0000000..53f7365 --- /dev/null +++ b/java8-to-25/probes/mixed/src/main/java/Mixed.java @@ -0,0 +1,16 @@ +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"; + } + + public static void main(String[] args) throws Exception { + StringWriter out = new StringWriter(); + JAXBContext.newInstance(Order.class).createMarshaller().marshal(new Order(), out); + System.out.println(out); + } +} diff --git a/java8-to-25/probes/tls/CryptoDefaults.java b/java8-to-25/probes/tls/CryptoDefaults.java new file mode 100644 index 0000000..ec85b36 --- /dev/null +++ b/java8-to-25/probes/tls/CryptoDefaults.java @@ -0,0 +1,67 @@ +import java.io.FileInputStream; +import java.security.KeyStore; +import java.security.Security; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.TrustManagerFactory; + +/** Prints the TLS and keystore defaults of the running JDK and tries three handshakes. + * Usage: java CryptoDefaults keystore.p12 (store password "changeit"). Compiles on JDK 8. */ +public class CryptoDefaults { + public static void main(String[] args) throws Exception { + System.out.println("java.version = " + System.getProperty("java.version")); + System.out.println("keystore.type = " + KeyStore.getDefaultType()); + SSLParameters p = SSLContext.getDefault().getDefaultSSLParameters(); + System.out.println("protocols = " + Arrays.toString(p.getProtocols())); + List rsaKx = new ArrayList(); + for (String s : p.getCipherSuites()) if (s.startsWith("TLS_RSA_")) rsaKx.add(s); + System.out.println("cipher suites = " + p.getCipherSuites().length + " enabled, " + + rsaKx.size() + " of them TLS_RSA_*"); + for (String key : new String[] {"jdk.tls.disabledAlgorithms", "jdk.jar.disabledAlgorithms"}) { + System.out.println(key + " ="); + for (String item : Security.getProperty(key).split(",")) System.out.println(" " + item.trim()); + } + + KeyStore ks = KeyStore.getInstance("PKCS12"); + try (FileInputStream in = new FileInputStream(args[0])) { ks.load(in, "changeit".toCharArray()); } + KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + kmf.init(ks, "changeit".toCharArray()); + TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + tmf.init(ks); + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + + handshake(ctx, "TLSv1.2 default suites", "TLSv1.2", null); + handshake(ctx, "TLSv1.1 only", "TLSv1.1", null); + handshake(ctx, "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLSv1.2", "TLS_RSA_WITH_AES_128_GCM_SHA256"); + } + + static void handshake(SSLContext ctx, String label, String protocol, String suite) throws Exception { + final SSLServerSocket server = (SSLServerSocket) ctx.getServerSocketFactory().createServerSocket(0); + server.setEnabledProtocols(new String[] {"TLSv1.2", "TLSv1.1"}); + server.setEnabledCipherSuites(server.getSupportedCipherSuites()); + Thread t = new Thread(() -> { + try (SSLSocket s = (SSLSocket) server.accept()) { s.startHandshake(); s.getOutputStream().write(1); } + catch (Exception ignored) { } + }); + t.start(); + try (SSLSocket c = (SSLSocket) ctx.getSocketFactory().createSocket("localhost", server.getLocalPort())) { + c.setEnabledProtocols(new String[] {protocol}); + if (suite != null) c.setEnabledCipherSuites(new String[] {suite}); + c.startHandshake(); + c.getInputStream().read(); + System.out.println("[ok] " + label + " -> " + c.getSession().getProtocol() + " " + c.getSession().getCipherSuite()); + } catch (Exception e) { + System.out.println("[FAIL] " + label + " -> " + e.getClass().getName() + ": " + e.getMessage()); + } finally { + t.join(3000); + server.close(); + } + } +} diff --git a/java8-to-25/scripts/01-legacy.sh b/java8-to-25/scripts/01-legacy.sh new file mode 100755 index 0000000..360bc0b --- /dev/null +++ b/java8-to-25/scripts/01-legacy.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# The legacy app: build and run on 8, run the SAME classes on 25, then try to compile on 25. +source "$(dirname "$0")/env.sh" +cd "$ROOT/legacy" +SRC=$(find src -name '*.java' | sort) +rm -rf "$WORK/c8" "$WORK/c25" "$WORK/r8"; mkdir -p "$WORK/c8" "$WORK/c25" "$WORK/r8" + +{ echo '$ javac -version # JDK 8, no -encoding flag, LANG=C' + "$JDK8/bin/javac" -d "$WORK/c8" $SRC 2>&1 | clean; } > "$OUT/01-jdk8-compile-no-encoding.txt" +"$JDK8/bin/javac" -encoding UTF-8 -nowarn -d "$WORK/c8" $SRC 2>&1 | clean + +{ echo '$ java -version'; "$JDK8/bin/java" -version 2>&1 | clean + echo; echo '$ java -cp classes-built-by-jdk8 com.ankurm.legacy.App' + "$JDK8/bin/java" -cp "$WORK/c8" com.ankurm.legacy.App 2>&1 | clean; } > "$OUT/02-run-on-jdk8.txt" + +{ echo '$ java -version'; "$JDK25/bin/java" -version 2>&1 | clean + echo; echo '$ java -cp classes-built-by-jdk8 com.ankurm.legacy.App' + "$JDK25/bin/java" -cp "$WORK/c8" com.ankurm.legacy.App 2>&1 | clean; } > "$OUT/03-jdk8-classes-on-jdk25.txt" + +{ echo '$ javac -encoding UTF-8 ... # JDK 25' + "$JDK25/bin/javac" -encoding UTF-8 -d "$WORK/c25" $SRC 2>&1 | clean; } > "$OUT/04-jdk25-compile.txt" + +{ echo '$ javac --release 8 ... # JDK 25, all sources except Tokens.java and App.java' + "$JDK25/bin/javac" --release 8 -encoding UTF-8 -d "$WORK/r8" $(find src -name '*.java' | grep -v -e Tokens -e App.java | sort) 2>&1 | clean + echo "exit status: ${PIPESTATUS[0]}" + echo; echo '$ ls r8/com/ankurm/legacy'; ls "$WORK/r8/com/ankurm/legacy" + echo; echo '$ javac --release 8 Tokens.java' + "$JDK25/bin/javac" -Xlint:-options --release 8 -d "$WORK/r8" src/main/java/com/ankurm/legacy/Tokens.java 2>&1 | clean +} > "$OUT/05-jdk25-release8.txt" + +if [ -n "${JDK17:-}" ]; then +{ echo '$ java -cp classes-built-by-jdk8 com.ankurm.legacy.App # JDK 17, the middle of the staged path' + "$JDK17/bin/java" -cp "$WORK/c8" com.ankurm.legacy.App 2>&1 | clean; } > "$OUT/03b-jdk8-classes-on-jdk17.txt" +fi diff --git a/java8-to-25/scripts/02-analyse.sh b/java8-to-25/scripts/02-analyse.sh new file mode 100755 index 0000000..8534223 --- /dev/null +++ b/java8-to-25/scripts/02-analyse.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# What jdeps and jdeprscan can and cannot see in the JDK 8 jar. Run 01-legacy.sh first. +source "$(dirname "$0")/env.sh" +"$JDK25/bin/jar" --create --file "$WORK/legacy.jar" -C "$WORK/c8" . 2>&1 | clean +cd "$WORK" +{ echo '$ jdeps --jdk-internals legacy.jar'; "$JDK25/bin/jdeps" --jdk-internals legacy.jar 2>&1 | clean; } > "$OUT/06-jdeps-jdk-internals.txt" +{ echo '$ jdeps -verbose:package legacy.jar'; "$JDK25/bin/jdeps" -verbose:package legacy.jar 2>&1 | clean; } > "$OUT/07-jdeps-packages.txt" +{ echo '$ jdeprscan --release 25 legacy.jar'; "$JDK25/bin/jdeprscan" --release 25 legacy.jar 2>&1 | clean; } > "$OUT/08-jdeprscan.txt" diff --git a/java8-to-25/scripts/03-flags.sh b/java8-to-25/scripts/03-flags.sh new file mode 100755 index 0000000..fe41496 --- /dev/null +++ b/java8-to-25/scripts/03-flags.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# One JDK 8 era option at a time: java -version on 8, 17 and 25. +source "$(dirname "$0")/env.sh" +JDK17=${JDK17:?set JDK17 to a JDK 17 home} +mkdir -p "$WORK/flags"; cd "$WORK/flags" +{ +while read -r flag; do + [ -z "$flag" ] && continue + echo "################ $flag" + for pair in "8:$JDK8" "17:$JDK17" "25:$JDK25"; do + v=${pair%%:*}; home=${pair#*:} + o=$("$home/bin/java" -XX:-UsePerfData $flag -version 2>&1); rc=$? + echo "JDK $v exit=$rc" + echo "$o" | clean | sed "s#$JDK17#\$JDK17#g" | grep -v -e 'openjdk version' -e 'Runtime Environment' -e 'Server VM (' -e "$JDK17" | head -4 | sed -e 's/^/ /' -e 's/\[0\.[0-9]*s\]/[0.0NNs]/' + done +done < "$ROOT/flags/jdk8-flags.txt" +} > "$OUT/09-jvm-flags.txt" diff --git a/java8-to-25/scripts/04-gc-crypto.sh b/java8-to-25/scripts/04-gc-crypto.sh new file mode 100755 index 0000000..8141f01 --- /dev/null +++ b/java8-to-25/scripts/04-gc-crypto.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# GC and heap defaults, TLS/keystore defaults, and a SHA-1 signed jar. Needs JDK17 too. +source "$(dirname "$0")/env.sh" +JDK17=${JDK17:?set JDK17 to a JDK 17 home} +rm -rf "$WORK/tls"; mkdir -p "$WORK/tls"; cd "$WORK/tls" + +{ for pair in "8:$JDK8" "17:$JDK17" "25:$JDK25"; do + v=${pair%%:*}; home=${pair#*:} + for cpus in 2 1; do + echo "################ JDK $v, -XX:ActiveProcessorCount=$cpus" + if [ "$v" = 8 ] && ! "$home/bin/java" -XX:ActiveProcessorCount=$cpus -version >/dev/null 2>&1; then echo "flag not supported"; continue; fi + "$home/bin/java" -XX:ActiveProcessorCount=$cpus -XX:+PrintFlagsFinal -version 2>/dev/null | + awk '$2 ~ /^(UseSerialGC|UseParallelGC|UseG1GC|UseCompressedOops|UseCompactObjectHeaders|MaxHeapSize|UseContainerSupport|UseStringDeduplication)$/ {printf " %-24s %s\n", $2, $4}' | sort + done + done + echo "################ JDK 8 with 1 CPU: no UseXxxGC flag is set, so ask for the heap layout" + "$JDK8/bin/java" -XX:ActiveProcessorCount=1 -XX:+PrintGCDetails -version 2>&1 | clean | grep -e generation -e PSYoungGen | sed 's/ *total.*//'; } > "$OUT/10-gc-defaults.txt" + +"$JDK25/bin/keytool" -genkeypair -keystore ks.p12 -storepass changeit -alias k -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -dname CN=localhost -ext san=dns:localhost -validity 3650 2>&1 | clean >/dev/null +"$JDK8/bin/javac" -d . "$ROOT/probes/tls/CryptoDefaults.java" 2>&1 | clean +{ for pair in "8:$JDK8" "17:$JDK17" "25:$JDK25"; do + v=${pair%%:*}; home=${pair#*:} + echo "################ JDK $v" + "$home/bin/java" -cp . CryptoDefaults ks.p12 2>&1 | clean + done; } > "$OUT/11-tls-crypto-defaults.txt" + +# A jar signed the old way (SHA-1 digest, SHA1withRSA) on JDK 8, then verified on 8 and 25. +echo hello > hello.txt +"$JDK8/bin/jar" cf signed.jar hello.txt 2>&1 | clean +"$JDK8/bin/keytool" -genkeypair -keystore sign.jks -storepass changeit -keypass changeit -alias s -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -dname CN=build -validity 3650 2>&1 | clean >/dev/null +"$JDK8/bin/jarsigner" -keystore sign.jks -storepass changeit -digestalg SHA-1 -sigalg SHA1withRSA signed.jar s 2>&1 | clean >/dev/null +{ for pair in "8:$JDK8" "25:$JDK25"; do + v=${pair%%:*}; home=${pair#*:} + echo "################ JDK $v: jarsigner -verify signed.jar" + "$home/bin/jarsigner" -verify signed.jar 2>&1 | clean | head -14 + done; } > "$OUT/12-sha1-signed-jar.txt" diff --git a/java8-to-25/scripts/05-bridge-fixed-rewrite.sh b/java8-to-25/scripts/05-bridge-fixed-rewrite.sh new file mode 100755 index 0000000..af8d316 --- /dev/null +++ b/java8-to-25/scripts/05-bridge-fixed-rewrite.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Needs Maven. Stage 1 (old bytecode on 25 with stopgaps), the fixed app, and OpenRewrite. +# Set MVN_SETTINGS to use a mirror. Run 01-legacy.sh first. +source "$(dirname "$0")/env.sh" +MVN="mvn -B ${MVN_SETTINGS:+-s $MVN_SETTINGS}" + +(cd "$ROOT/bridge" && JAVA_HOME=$JDK25 $MVN -q dependency:copy-dependencies 2>&1 | grep ERROR) +CP="$WORK/c8:$(ls "$ROOT"/bridge/target/dependency/*.jar | tr '\n' ':')" +{ echo '$ java --add-opens java.base/java.util=ALL-UNNAMED -Dfile.encoding=COMPAT -Djava.locale.providers=COMPAT \' + echo ' -cp classes-built-by-jdk8:bridge-jars com.ankurm.legacy.App # JDK 25' + "$JDK25/bin/java" --add-opens java.base/java.util=ALL-UNNAMED -Dfile.encoding=COMPAT -Djava.locale.providers=COMPAT -cp "$CP" com.ankurm.legacy.App 2>&1 | clean; } > "$OUT/13-bridge-on-jdk25.txt" + +(cd "$ROOT/fixed" && JAVA_HOME=$JDK25 $MVN -q clean compile dependency:copy-dependencies 2>&1 | grep -v -e '^Picked' -e '^WARNING' ) +{ echo '$ java -cp target/classes:target/dependency/* com.ankurm.fixed.App # JDK 25' + cd "$ROOT/fixed" && "$JDK25/bin/java" -cp "target/classes:target/dependency/*" com.ankurm.fixed.App 2>&1 | clean | sed -e 's/^[A-Z][a-z][a-z] [0-9][0-9], [0-9]* [0-9:]* [AP]M / /'; } > "$OUT/14-fixed-on-jdk25.txt" + +# OpenRewrite on a throwaway copy, run on JDK 8 (the code still builds there). +rm -rf "$WORK/rw"; cp -r "$ROOT/legacy" "$WORK/rw"; rm -rf "$WORK/rw/target" +cd "$WORK/rw"; git init -q; git add -A; git -c user.name=demo -c user.email=demo@example.com commit -qm base +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; } +git diff --stat > "$OUT/15-openrewrite-diff.txt"; echo >> "$OUT/15-openrewrite-diff.txt"; git diff >> "$OUT/15-openrewrite-diff.txt" + +{ echo '$ mvn clean compile # JDK 25, straight after the recipe' + JAVA_HOME=$JDK25 $MVN clean compile 2>&1 | clean | grep -e 'ERROR.*java' -e 'BUILD' | head -4 | sed 's#\./build/rw/##'; } > "$OUT/16-openrewrite-build.txt" + +# One hand edit (replace the injected throw) so the rest can be run. +python3 -I - <<'PY' +p = 'src/main/java/com/ankurm/legacy/Watchdog.java' +s = open(p).read() +a = s.index(' /*\n * `Thread'); b = s.index('worker.join') +open(p, 'w').write(s[:a] + ' worker.interrupt(); // hand edit\n ' + s[b:]) +PY +JAVA_HOME=$JDK25 $MVN -q clean compile dependency:copy-dependencies -DincludeScope=runtime 2>&1 | grep '^\[ERROR' +{ echo '$ java ... # JDK 25, recipe output plus the one hand edit, runtime classpath' + "$JDK25/bin/java" -cp "target/classes:target/dependency/*" com.ankurm.legacy.App 2>&1 | clean; } > "$OUT/17-openrewrite-run.txt" + +# The JAXB/JAX-WS 2.3 jars can already be added while production is still on 8 (nashorn-core needs a newer JDK). +CP8="$WORK/c8:$(ls "$ROOT"/bridge/target/dependency/*.jar | grep -v nashorn | tr '\n' ':')" +{ echo '$ java -cp classes-built-by-jdk8:bridge-jars-without-nashorn com.ankurm.legacy.App # JDK 8' + "$JDK8/bin/java" -cp "$CP8" com.ankurm.legacy.App 2>&1 | clean; } > "$OUT/27-bridge-jars-on-jdk8.txt" diff --git a/java8-to-25/scripts/06-libraries.sh b/java8-to-25/scripts/06-libraries.sh new file mode 100755 index 0000000..defb047 --- /dev/null +++ b/java8-to-25/scripts/06-libraries.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# Which versions of common build-time libraries work on JDK 25. Downloads jars with curl; needs Maven for Boot. +source "$(dirname "$0")/env.sh" +REPO=${REPO:-https://repo1.maven.org/maven2} +MVN="mvn -B ${MVN_SETTINGS:+-s $MVN_SETTINGS}" +J="$JDK25/bin/java"; JC="$JDK25/bin/javac" +W="$WORK/libs"; rm -rf "$W"; mkdir -p "$W/jars"; cd "$W" +get() { # groupPath artifact version + [ -f "jars/$2-$3.jar" ] || curl -sSf -o "jars/$2-$3.jar" "$REPO/$1/$2/$3/$2-$3.jar"; } +head3() { clean | grep -v -e '^WARNING' -e '^\s*at ' | head -${1:-4}; } + +{ for v in 1.18.20 1.18.36 1.18.38 1.18.40 1.18.48; do + get org/projectlombok lombok $v; rm -rf lb; mkdir lb + echo "################ lombok $v with -processorpath" + if "$JC" -d lb -cp jars/lombok-$v.jar -processorpath jars/lombok-$v.jar "$ROOT/probes/libs/LombokBean.java" > lb.log 2>&1; then + "$J" -cp lb LombokBean 2>&1 | clean; else clean < lb.log | grep -m3 -e "uncaught exception" -e "Error:" -e "Exception:" -e "^error" | cut -c1-230; fi + done + rm -rf lb; mkdir lb + echo "################ lombok 1.18.48 on the class path only (what a pom with just the dependency does)" + if "$JC" -d lb -cp jars/lombok-1.18.48.jar "$ROOT/probes/libs/LombokBean.java" > lb.log 2>&1; then + "$J" -cp lb LombokBean 2>&1 | clean; else head3 12 < lb.log; fi +} > "$OUT/18-lombok.txt" + +{ for pair in "2.28.2 1.9.10 2.6" "4.11.0 1.12.19 3.3" "5.14.2 1.15.11 3.3" "5.25.0 1.18.17 3.3"; do + set -- $pair; get org/mockito mockito-core $1; get net/bytebuddy byte-buddy $2; get net/bytebuddy byte-buddy-agent $2; get org/objenesis objenesis $3 + CP="jars/mockito-core-$1.jar:jars/byte-buddy-$2.jar:jars/byte-buddy-agent-$2.jar:jars/objenesis-$3.jar" + rm -rf mk; mkdir mk; "$JC" -d mk -cp "$CP" "$ROOT/probes/libs/MockDemo.java" 2>&1 | clean + echo "################ mockito-core $1 (byte-buddy $2)" + "$J" -cp "mk:$CP" MockDemo > mk.log 2>&1 + clean < mk.log | grep -e 'mocked price' -e 'Mockito cannot mock' -e 'Java 25 (69)' -e 'Could not initialize' | head -3 | cut -c1-230 + done; } > "$OUT/19-mockito.txt" + +{ for v in 9.2 9.7.1 9.8 9.11.1; do + get org/ow2/asm asm $v; rm -rf as; mkdir as; "$JC" -d as -cp jars/asm-$v.jar "$ROOT/probes/libs/AsmRead.java" 2>&1 | clean + echo "################ asm $v" + "$J" -cp as:jars/asm-$v.jar AsmRead 2>&1 | head3 1 + done; } > "$OUT/20-asm.txt" + +{ rm -rf jc; mkdir jc; "$JC" -d jc "$ROOT/probes/libs/Hello.java" 2>&1 | clean + for v in 0.8.11 0.8.13 0.8.14 0.8.16; do + curl -sSf -o jars/jacoco-agent-$v.jar "$REPO/org/jacoco/org.jacoco.agent/$v/org.jacoco.agent-$v-runtime.jar" 2>/dev/null || + curl -sSf -o jars/jacoco-agent-$v.jar "$REPO/org/jacoco/org.jacoco.agent/$v/org.jacoco.agent-$v-runtime.jar" + echo "################ jacoco agent $v" + "$J" -javaagent:jars/jacoco-agent-$v.jar=destfile=jc/x.exec -cp jc Hello > jc.log 2>&1 + clean < jc.log | grep -e '^hello' -e 'Unsupported class file' | head -2 | cut -c1-200 + done; } > "$OUT/21-jacoco.txt" + +(cd "$ROOT/probes/libs/boot27" && JAVA_HOME=$JDK25 $MVN -q dependency:copy-dependencies -DoutputDirectory="$W/boot" 2>&1 | grep ERROR) +{ for rel in 8 25; do + rm -rf bt; mkdir bt + "$JC" -Xlint:-options --release $rel -d bt -cp "boot/*" "$ROOT"/probes/libs/boot27/app/*.java 2>&1 | clean + echo "################ Spring Boot 2.7.18 on JDK 25, application compiled with --release $rel" + "$J" -cp "bt:boot/*" app.DemoApp --spring.main.banner-mode=off > bt.log 2>&1 + clean < bt.log | grep -e 'context started' -e 'Unsupported class file' -e 'ASM ClassReader' | head -3 | cut -c1-260 + done; } > "$OUT/22-boot27.txt" diff --git a/java8-to-25/scripts/07-build-tools.sh b/java8-to-25/scripts/07-build-tools.sh new file mode 100755 index 0000000..119c1c9 --- /dev/null +++ b/java8-to-25/scripts/07-build-tools.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Old compiler levels in Maven, and an installed Gradle (set GRADLE) running on JDK 25. +source "$(dirname "$0")/env.sh" +MVN="mvn -B ${MVN_SETTINGS:+-s $MVN_SETTINGS}" +rm -rf "$WORK/build-probe"; cp -r "$ROOT/probes/build" "$WORK/build-probe" +{ cd "$WORK/build-probe/old-source" + for level in 1.7 1.8; do + echo "################ maven.compiler.source/target=$level, JDK 25" + JAVA_HOME=$JDK25 $MVN clean compile -Dlevel=$level 2>&1 | clean | grep -e '^\[ERROR\].*option' -e 'obsolete' -e 'BUILD' | head -5 + done; } > "$OUT/23-maven-old-levels.txt" +if [ -n "${GRADLE:-}" ]; then +{ cd "$WORK/build-probe/gradle" + echo "\$ gradle compileJava # $("$GRADLE" --version 2>/dev/null | grep '^Gradle'), JAVA_HOME = JDK 25" + JAVA_HOME=$JDK25 "$GRADLE" --no-daemon -q compileJava > g.log 2>&1; echo "exit status: $?" + clean < g.log | grep -v '^\s*$' | head -12 | cut -c1-220; } > "$OUT/24-gradle-on-25.txt" +fi diff --git a/java8-to-25/scripts/08-namespaces.sh b/java8-to-25/scripts/08-namespaces.sh new file mode 100755 index 0000000..99b4021 --- /dev/null +++ b/java8-to-25/scripts/08-namespaces.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# javax versus jakarta: what is in the JDK, and what a half-migrated classpath does. Needs Maven. +source "$(dirname "$0")/env.sh" +MVN="mvn -B ${MVN_SETTINGS:+-s $MVN_SETTINGS}" +{ echo '$ java JavaxMap.java # JDK 25'; "$JDK25/bin/java" "$ROOT/probes/javax/JavaxMap.java" 2>&1 | clean; } > "$OUT/25-javax-packages.txt" +cd "$ROOT/probes/mixed" +JAVA_HOME=$JDK25 $MVN -q clean compile dependency:copy-dependencies 2>&1 | grep '^\[ERROR' +{ echo '$ java Mixed # javax annotations on the bean, jakarta JAXB runtime' + "$JDK25/bin/java" -cp "target/classes:target/dependency/*" Mixed 2>&1 | clean | grep -v '^\s*at ' | head -14; } > "$OUT/26-mixed-namespaces.txt" diff --git a/java8-to-25/scripts/env.sh b/java8-to-25/scripts/env.sh new file mode 100755 index 0000000..8680ac7 --- /dev/null +++ b/java8-to-25/scripts/env.sh @@ -0,0 +1,12 @@ +# Shared settings. Override with: export JDK8=/path/to/jdk8 JDK25=/path/to/jdk-25 +set -u +ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +JDK8=${JDK8:?set JDK8 to a JDK 8 home} +JDK25=${JDK25:?set JDK25 to a JDK 25 home} +OUT=$ROOT/output +WORK=$ROOT/build +mkdir -p "$OUT" "$WORK" +unset _JAVA_OPTIONS +export LANG=C LC_ALL=C +# Strip launcher banners about environment options, and machine paths, from transcripts. +clean() { grep -v -e '^Picked up ' | sed -e "s#$ROOT#.#g" -e "s#$JDK8#\$JDK8#g" -e "s#$JDK25#\$JDK25#g"; } diff --git a/java8-to-25/scripts/run-all.sh b/java8-to-25/scripts/run-all.sh new file mode 100755 index 0000000..a30f35f --- /dev/null +++ b/java8-to-25/scripts/run-all.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# Regenerates every file in output/. Needs JDK8, JDK17, JDK25 and Maven; GRADLE is optional. +cd "$(dirname "$0")" +for s in 01-legacy 02-analyse 03-flags 04-gc-crypto 05-bridge-fixed-rewrite 06-libraries 07-build-tools 08-namespaces; do + echo "== $s"; ./$s.sh +done