From 3ed9299b80a42a0fffc3cddcd8492477b5a78505 Mon Sep 17 00:00:00 2001 From: Annelore Egger Date: Sat, 22 Nov 2025 12:49:59 +0100 Subject: [PATCH 1/5] Make addExports_manifest compatible with Java 25 --- jigsaw-examples/example_addExports_manifest/compile.sh | 2 +- .../example_addExports_manifest/expected-result/run.txt | 4 ++-- jigsaw-examples/example_addExports_manifest/m4/compile.sh | 6 +++--- jigsaw-examples/example_addExports_manifest/m4/pom.xml | 4 ++-- jigsaw-examples/example_addExports_manifest/m4/run.sh | 2 +- jigsaw-examples/example_addExports_manifest/run.sh | 2 +- .../src/modmain/META-INF/MANIFEST.MF | 2 +- .../src/modmain/pkgmain/Main.java | 8 ++++---- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jigsaw-examples/example_addExports_manifest/compile.sh b/jigsaw-examples/example_addExports_manifest/compile.sh index 81bc0123..b5f525a1 100755 --- a/jigsaw-examples/example_addExports_manifest/compile.sh +++ b/jigsaw-examples/example_addExports_manifest/compile.sh @@ -31,7 +31,7 @@ echo "javac ${JAVAC_OPTIONS} -d mods --module-path mlib --module-source-path sr # shellcheck disable=SC2046,SC2086 # Word splitting is intentional for find results; option variables should not be quoted "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d mods \ --module-path mlib \ - --add-exports java.base/jdk.internal.misc=modmain \ + --add-exports java.base/jdk.internal.org.xml.sax=modmain \ --add-exports moda/pkgainternal=modmain \ --module-source-path src $(find src/modmain -name '*.java') \ 2>&1 diff --git a/jigsaw-examples/example_addExports_manifest/expected-result/run.txt b/jigsaw-examples/example_addExports_manifest/expected-result/run.txt index 619badc0..c57bb5b7 100644 --- a/jigsaw-examples/example_addExports_manifest/expected-result/run.txt +++ b/jigsaw-examples/example_addExports_manifest/expected-result/run.txt @@ -1,4 +1,4 @@ -Do you want to know a secret: jdk.internal.misc.SharedSecrets +I need InputSource: jdk.internal.org.xml.sax.InputSource from A -Do you want to know a secret: jdk.internal.misc.SharedSecrets +I need InputSource: jdk.internal.org.xml.sax.InputSource from A diff --git a/jigsaw-examples/example_addExports_manifest/m4/compile.sh b/jigsaw-examples/example_addExports_manifest/m4/compile.sh index 8b068d83..0a8bbc3d 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/compile.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/compile.sh @@ -13,9 +13,9 @@ fi # Maven 4 requires Java 17+ to run # Note: pom.xml uses source/target (not release) because --add-exports java.base # is incompatible with --release flag -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi +#if [ -n "${JAVA17_HOME:-}" ]; then +# export JAVA_HOME="${JAVA17_HOME}" +#fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" diff --git a/jigsaw-examples/example_addExports_manifest/m4/pom.xml b/jigsaw-examples/example_addExports_manifest/m4/pom.xml index 7d7ebe77..6cd73e3a 100644 --- a/jigsaw-examples/example_addExports_manifest/m4/pom.xml +++ b/jigsaw-examples/example_addExports_manifest/m4/pom.xml @@ -11,7 +11,7 @@ 11 - 11 + 25 UTF-8 @@ -37,7 +37,7 @@ ${env.JAVA11_HOME} --add-exports - java.base/jdk.internal.misc=modmain + java.base/jdk.internal.org.xml.sax=modmain --add-exports moda/pkgainternal=modmain diff --git a/jigsaw-examples/example_addExports_manifest/m4/run.sh b/jigsaw-examples/example_addExports_manifest/m4/run.sh index 7698bdbb..e50bce48 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/run.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/run.sh @@ -21,7 +21,7 @@ mkdir -p run-result # First run: Allow access to moda without using the "Add-Exports" entry from MANIFEST.MF # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} \ - --add-exports java.base/jdk.internal.misc=modmain \ + --add-exports java.base/jdk.internal.org.xml.sax=modmain \ --add-exports moda/pkgainternal=modmain \ --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_addExports_manifest/run.sh b/jigsaw-examples/example_addExports_manifest/run.sh index f37dd40f..d56bcbb1 100755 --- a/jigsaw-examples/example_addExports_manifest/run.sh +++ b/jigsaw-examples/example_addExports_manifest/run.sh @@ -13,7 +13,7 @@ touch "${result_dir}/run.txt" # Allow access to moda without using the "Add-Exports" entry from MANIFEST.MF # shellcheck disable=SC2086 # Option variables should not be quoted "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --add-exports java.base/jdk.internal.misc=modmain \ + --add-exports java.base/jdk.internal.org.xml.sax=modmain \ --add-exports moda/pkgainternal=modmain \ --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho diff --git a/jigsaw-examples/example_addExports_manifest/src/modmain/META-INF/MANIFEST.MF b/jigsaw-examples/example_addExports_manifest/src/modmain/META-INF/MANIFEST.MF index 6db4298b..0b186abb 100644 --- a/jigsaw-examples/example_addExports_manifest/src/modmain/META-INF/MANIFEST.MF +++ b/jigsaw-examples/example_addExports_manifest/src/modmain/META-INF/MANIFEST.MF @@ -1,4 +1,4 @@ Manifest-Version: 1.0 Created-By: 9-ea (Oracle Corporation) -Add-Exports: java.base/jdk.internal.misc moda/pkgainternal +Add-Exports: java.base/jdk.internal.org.xml.sax moda/pkgainternal Main-Class: pkgmain.Main diff --git a/jigsaw-examples/example_addExports_manifest/src/modmain/pkgmain/Main.java b/jigsaw-examples/example_addExports_manifest/src/modmain/pkgmain/Main.java index 91e4dd5b..7c765254 100644 --- a/jigsaw-examples/example_addExports_manifest/src/modmain/pkgmain/Main.java +++ b/jigsaw-examples/example_addExports_manifest/src/modmain/pkgmain/Main.java @@ -1,6 +1,6 @@ package pkgmain; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.org.xml.sax.InputSource; /** * This class cannot be compiled in Eclipse as compiler options --add-exports are needed. @@ -14,9 +14,9 @@ public class Main { public static void main(String[] args) { - // Compiler and also Runtime option needed: --add-exports java.base/jdk.internal.misc=modmain - SharedSecrets secrets = new SharedSecrets(); - System.out.println("Do you want to know a secret: " + secrets.getClass().getName()); + // Compiler and also Runtime option needed: --add-exports java.base/jdk.internal.org.xml.sax=modmain + InputSource inputSource = new InputSource(); + System.out.println("I need InputSource: " + inputSource.getClass().getName()); // Compiler and also Runtime option needed: --add-exports moda/pkgainternal=modmain System.out.println(new pkgainternal.A().doIt()); From 01ffb1b23e54b4aa1686a71bca09167804b2d699 Mon Sep 17 00:00:00 2001 From: Annelore Egger Date: Sat, 22 Nov 2025 14:50:45 +0100 Subject: [PATCH 2/5] Replace java11_path with java25_path in GH actions --- .github/workflows/build.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f306ad8..6988b2f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,13 +56,13 @@ jobs: distribution: 'zulu' java-version: '8' - - name: Set up JDK 11 - id: setup-jdk11 + - name: Set up JDK 25 + id: setup-jdk25 uses: actions/setup-java@v5 with: distribution: 'temurin' # tag::java-version-minimal[] - java-version: '11.0.28' + java-version: '25.0.1' # end::java-version-minimal[] - name: Set up JDK 17 @@ -76,13 +76,13 @@ jobs: shell: bash env: JAVA8_PATH: ${{ steps.setup-jdk8.outputs.path || steps.setup-jdk8-mac.outputs.path }} - JAVA11_PATH: ${{ steps.setup-jdk11.outputs.path }} + JAVA25_PATH: ${{ steps.setup-jdk25.outputs.path }} JAVA17_PATH: ${{ steps.setup-jdk17.outputs.path }} run: | # Convert Windows paths to Unix paths if on Windows if [[ "$RUNNER_OS" == "Windows" ]]; then JAVA8_PATH="$(cygpath -u "$JAVA8_PATH")" - JAVA11_PATH="$(cygpath -u "$JAVA11_PATH")" + JAVA25_PATH="$(cygpath -u "$JAVA25_PATH")" JAVA17_PATH="$(cygpath -u "$JAVA17_PATH")" fi @@ -94,7 +94,7 @@ jobs: export JAVA17_HOME=$JAVA17_PATH # Path to JDK 11 (required for most examples, JDK 17 is also fine) - export JAVA_HOME=$JAVA11_PATH + export JAVA_HOME=$JAVA25_PATH # Path to JDK 8 (only needed for example_compile-target-jdk8) export JAVA8_HOME=$JAVA8_PATH @@ -190,12 +190,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 - - name: Set up JDK 11 - id: setup-jdk11 + - name: Set up JDK 25 + id: setup-jdk25 uses: actions/setup-java@v5 with: distribution: 'temurin' - java-version: '11.0.28' + java-version: '25.0.1' - name: Set up JDK 17 id: setup-jdk17 @@ -214,7 +214,7 @@ jobs: - name: Create .envrc with Java and Maven paths shell: bash env: - JAVA11_PATH: ${{ steps.setup-jdk11.outputs.path }} + JAVA25_PATH: ${{ steps.setup-jdk25.outputs.path }} JAVA17_PATH: ${{ steps.setup-jdk17.outputs.path }} run: | # Detect Maven home @@ -233,7 +233,7 @@ jobs: # Convert Windows paths to Unix paths if on Windows if [[ "$RUNNER_OS" == "Windows" ]]; then - JAVA11_PATH="$(cygpath -u "$JAVA11_PATH")" + JAVA25_PATH="$(cygpath -u "$JAVA25_PATH")" JAVA17_PATH="$(cygpath -u "$JAVA17_PATH")" MAVEN4_PATH="$(cygpath -u "$MAVEN4_PATH")" fi @@ -249,7 +249,7 @@ jobs: export JAVA_HOME=$JAVA17_PATH # Path to JDK 11 (for compatibility with examples that need it) - export JAVA11_HOME=$JAVA11_PATH + export JAVA11_HOME=$JAVA25_PATH # Path to Maven 4 (required for m4 builds) export M4_HOME=$MAVEN4_PATH From 7847d4f2e17bf51f0a7bdcddc24de2791ef25536 Mon Sep 17 00:00:00 2001 From: Annelore Egger Date: Tue, 25 Nov 2025 08:54:45 +0100 Subject: [PATCH 3/5] Use java 25 almost everywhere to remove no longer used workaround Before java 11 was used for most examples, but for maven to run also java 17 was used. --- .envrc-template | 14 +++----- jigsaw-examples/env.sh | 14 +++----- .../example_addExports_manifest/m4/compile.sh | 2 +- .../example_addExports_manifest/m4/run.sh | 12 ++----- .../example_addReads_addExports/m4/compile.sh | 9 +---- .../m4/compile.sh | 9 +---- .../example_annotations/m4/compile.sh | 9 +---- .../m4/compile.sh | 9 +---- .../m4/compile.sh | 9 +---- .../example_exceptions/m4/compile.sh | 9 +---- .../example_hiddenmain/m4/compile.sh | 9 +---- .../example_interface-callback/m4/compile.sh | 9 +---- .../example_jerrymouse/m4/compile.sh | 9 +---- .../example_layer-hierarchy/m4/compile.sh | 14 +++----- .../example_layer-hierarchy/m4/run.sh | 10 ++---- .../m4/compile.sh | 21 +++-------- .../m4/run.sh | 12 ------- .../m4/compile.sh | 36 +++++++------------ .../m4/run.sh | 12 ------- .../m4/compile.sh | 21 +++-------- .../m4/run.sh | 7 ++-- .../example_naming-modules/m4/compile.sh | 21 +++-------- jigsaw-examples/example_patch/m4/compile.sh | 6 ++-- .../example_reflection/m4/compile.sh | 9 +---- .../example_requires-static/m4/compile.sh | 9 +---- .../example_requires_exports-to/m4/compile.sh | 9 +---- .../example_requires_exports/m4/compile.sh | 9 +---- .../m4/compile.sh | 9 +---- .../example_resolved-modules/m4/compile.sh | 9 +---- .../example_resolved-modules/m4/run.sh | 12 ------- .../example_resources/m4/compile.sh | 9 +---- .../example_splitpackage/m4/compile.sh | 9 +---- .../m4/compile.sh | 21 +++-------- .../m4/run.sh | 12 ------- .../example_test/m4/compile-whiteboxtest.sh | 13 +++---- .../m4/compile.sh | 23 +++--------- .../m4/run.sh | 13 ------- .../m4/compile.sh | 18 ++++------ .../m4/compile.sh | 21 +++-------- .../m4/compile.sh | 21 +++-------- .../m4/compile.sh | 21 +++-------- .../example_uses-provides/m4/compile.sh | 9 +---- .../m4/compile.sh | 9 +---- jigsaw-examples/example_version/m4/compile.sh | 9 +---- jigsaw-examples/example_version/m4/run.sh | 7 ++-- 45 files changed, 101 insertions(+), 463 deletions(-) diff --git a/.envrc-template b/.envrc-template index bec5e035..9c3602d1 100644 --- a/.envrc-template +++ b/.envrc-template @@ -10,20 +10,14 @@ # Note: This file contains the minimal environment variables needed to run the examples. # For more configuration options, see jigsaw-examples/env.sh # +# todo: is this still true, or does it rather automatically configure JDK 25.0.1 # SDKMAN Users: If you use SDKMAN with sdkman_auto_env=true, the .sdkmanrc file # will automatically configure JDK 11.0.28. This may interfere with JAVA_HOME # settings below. Either disable sdkman_auto_env or ensure paths match. -# Path to JDK 17 or later (required for example_gradle-project with Gradle 9.x) -export JAVA17_HOME=/path/to/jdk17 - -# Path to JDK 9, 10, or 11 (required for most examples, JDK 17 is also fine) -# Strongly recommended: JDK 11.0.28 (Temurin) - cf. README -export JAVA_HOME=/path/to/java9-or-10-or-11-jdk - -# Path to JDK 11 specifically (required for examples that need JDK 11) -# Strongly recommended: JDK 11.0.28 (Temurin) - cf. README -export JAVA11_HOME=/path/to/java11-jdk +# Path to JDK 25 (required for most examples) +# Strongly recommended: JDK 25.0.1 (Temurin) - cf. README +export JAVA_HOME=/path/to/java25-jdk # Path to JDK 8 (only needed for example_compile-target-jdk8) # If you want to explicitly test with JDK 8 diff --git a/jigsaw-examples/env.sh b/jigsaw-examples/env.sh index 9985d152..20f38ca3 100644 --- a/jigsaw-examples/env.sh +++ b/jigsaw-examples/env.sh @@ -5,20 +5,14 @@ set -eu -o pipefail # configure paths here -# Path to JDK9 or JDK10 (9.0.1, 9.0.4 and 10_18.3_10+46 have been tested) -# Recommended: JDK 11.0.28 (Temurin) - same as CI/CD pipeline -# SDKMAN Users: .sdkmanrc at repository root configures JDK 11.0.28 automatically -[ -z "${JAVA_HOME:-}" ] && export JAVA_HOME=TODO/path/to/java9-or-10-jdk/goes/here +# Path to JDK25 +# Recommended: JDK 25.0.1 (Temurin) - same as CI/CD pipeline +# SDKMAN Users: .sdkmanrc at repository root configures JDK 25.0.1 automatically +[ -z "${JAVA_HOME:-}" ] && export JAVA_HOME=TODO/path/to/java25-jdk/goes/here # Path to JDK8, only needed in example_compile-target-jdk8 (and special profile in example_spring-hibernate) [ -z "${JAVA8_HOME:-}" ] && export JAVA8_HOME=TODO/path/to/java8-jdk/goes/here -# Path to JDK11, only needed for specific examples (e.g., example_version/m4 runtime) -[ -z "${JAVA11_HOME:-}" ] && export JAVA11_HOME=TODO/path/to/java11-jdk/goes/here - -# Path to JDK17, only needed in example_gradle-project and Maven 4 builds -[ -z "${JAVA17_HOME:-}" ] && export JAVA17_HOME=TODO/path/to/java17-jdk/goes/here - # Path to Eclipse (legacy compatibility, not recommended for new work) [ -z "${ECLIPSE_HOME:-}" ] && export ECLIPSE_HOME=TODO/path/to/eclipse/goes/here diff --git a/jigsaw-examples/example_addExports_manifest/m4/compile.sh b/jigsaw-examples/example_addExports_manifest/m4/compile.sh index 0a8bbc3d..a2955e9e 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/compile.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/compile.sh @@ -26,6 +26,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, targets Java 11 via maven.compiler.source/target)" +echo "(Maven runs with JDK 17+, targets Java 25 via maven.compiler.source/target)" mvn clean package diff --git a/jigsaw-examples/example_addExports_manifest/m4/run.sh b/jigsaw-examples/example_addExports_manifest/m4/run.sh index e50bce48..459e13ca 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/run.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/run.sh @@ -4,15 +4,9 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# Use JDK 11 for runtime (required to access JDK 11 internals) -if [ -z "${JAVA11_HOME:-}" ]; then - echo "ERROR: JAVA11_HOME is not set. This example requires JDK 11 to run." - exit 1 -fi - # Show Java version for user information echo "Using Java version:" -"${JAVA11_HOME}/bin/java" -version +"${JAVA_HOME}/bin/java" -version echo # Create run-result directory if it doesn't exist @@ -20,14 +14,14 @@ mkdir -p run-result # First run: Allow access to moda without using the "Add-Exports" entry from MANIFEST.MF # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} \ +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ --add-exports java.base/jdk.internal.org.xml.sax=modmain \ --add-exports moda/pkgainternal=modmain \ --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho # Second run: Allow access to moda with using the "Add-Exports" entry from MANIFEST.MF # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} \ +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ --add-modules moda \ --module-path target \ -jar target/example_addExports_manifest-m4-1.0-SNAPSHOT-modmain.jar 2>&1 | normalize | tee -a run-result/run.txt | myecho diff --git a/jigsaw-examples/example_addReads_addExports/m4/compile.sh b/jigsaw-examples/example_addReads_addExports/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_addReads_addExports/m4/compile.sh +++ b/jigsaw-examples/example_addReads_addExports/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh b/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh +++ b/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_annotations/m4/compile.sh b/jigsaw-examples/example_annotations/m4/compile.sh index 37682871..e2b4aed4 100755 --- a/jigsaw-examples/example_annotations/m4/compile.sh +++ b/jigsaw-examples/example_annotations/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -25,5 +18,5 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_automatic-module-logging/m4/compile.sh b/jigsaw-examples/example_automatic-module-logging/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_automatic-module-logging/m4/compile.sh +++ b/jigsaw-examples/example_automatic-module-logging/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh b/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh +++ b/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_exceptions/m4/compile.sh b/jigsaw-examples/example_exceptions/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_exceptions/m4/compile.sh +++ b/jigsaw-examples/example_exceptions/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_hiddenmain/m4/compile.sh b/jigsaw-examples/example_hiddenmain/m4/compile.sh index 37682871..e2b4aed4 100755 --- a/jigsaw-examples/example_hiddenmain/m4/compile.sh +++ b/jigsaw-examples/example_hiddenmain/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -25,5 +18,5 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_interface-callback/m4/compile.sh b/jigsaw-examples/example_interface-callback/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_interface-callback/m4/compile.sh +++ b/jigsaw-examples/example_interface-callback/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_jerrymouse/m4/compile.sh b/jigsaw-examples/example_jerrymouse/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_jerrymouse/m4/compile.sh +++ b/jigsaw-examples/example_jerrymouse/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh index e371f30b..4dc4e002 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh @@ -10,10 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run, but we use JDK 11 for compilation -# Save JAVA17_HOME for Maven, restore JAVA_HOME for javac -MAVEN_JAVA_HOME="${JAVA17_HOME:-${JAVA_HOME}}" - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -25,10 +21,10 @@ mkdir -p target/classes # Step 1: Use Maven to download dependencies to amlib echo "=== Step 1: Download dependencies with Maven ===" echo -JAVA_HOME="${MAVEN_JAVA_HOME}" mvn --version +JAVA_HOME="${JAVA_HOME}" mvn --version echo echo "mvn initialize (copies javax.json to amlib/)" -JAVA_HOME="${MAVEN_JAVA_HOME}" mvn initialize +JAVA_HOME="${JAVA_HOME}" mvn initialize echo # Step 2: Compile mod.x* modules first (to avoid split package conflict with javax.json) @@ -36,10 +32,10 @@ echo echo "=== Step 2: Compile mod.x* modules (separate compilation with javac) ===" for modx in mod.x_bottom mod.x_middle mod.x_top do - echo "javac ${JAVAC_OPTIONS} --release 11 -d target/classes --module-path target${PATH_SEPARATOR}amlib --module-source-path \"src/*/main/java\" \$(find -L src/${modx}/main/java -name \"*.java\")" + echo "javac ${JAVAC_OPTIONS} --release 25 -d target/classes --module-path target${PATH_SEPARATOR}amlib --module-source-path \"src/*/main/java\" \$(find -L src/${modx}/main/java -name \"*.java\")" # shellcheck disable=SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting # shellcheck disable=SC2046 # Word splitting intentional for multiple Java source files - "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} --release 11 -d target/classes \ + "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} --release 25 -d target/classes \ --module-path target${PATH_SEPARATOR}amlib \ --module-source-path "src/*/main/java" \ $(find -L src/${modx}/main/java -name "*.java") 2>&1 @@ -49,7 +45,7 @@ echo # Step 3: Compile remaining 12 modules with Maven and create JARs echo "=== Step 3: Compile remaining 12 modules with Maven and create JARs ===" echo "mvn package" -JAVA_HOME="${MAVEN_JAVA_HOME}" mvn package +JAVA_HOME="${JAVA_HOME}" mvn package echo # Step 4: Create JARs in target/ (for modules compiled with javac, Maven-compiled modules already have JARs) diff --git a/jigsaw-examples/example_layer-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-hierarchy/m4/run.sh index 4abd8a46..db6fd07f 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/run.sh @@ -4,12 +4,6 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# Use JDK 11 for runtime (required for javax.json automatic module) -if [ -z "${JAVA11_HOME:-}" ]; then - echo "ERROR: JAVA11_HOME is not set. This example requires JDK 11 to run." - exit 1 -fi - # Create run-result directory if it doesn't exist mkdir -p run-result @@ -30,10 +24,10 @@ else fi echo "Using Java version:" -"${JAVA11_HOME}/bin/java" -version +"${JAVA_HOME}/bin/java" -version echo # Run the Java code, save output to run-result/run.txt, and display with highlighting # The '.' argument specifies the JSON file (layers_triple_hierarchy.json) location # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} --module-path "target${PATH_SEPARATOR}amlib" --module mod.main/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path "target${PATH_SEPARATOR}amlib" --module mod.main/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh index 95e283e5..2e94564b 100755 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -29,21 +22,15 @@ echo echo "Step 1: Compile automatic module (modauto1) manually" echo -# Reset JAVA_HOME to compilation JDK if needed -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - -echo "javac ${JAVAC_OPTIONS} -d classes/modauto1 --release 11 \$(find ../src/modauto1 -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d classes/modauto1 --release 25 \$(find ../src/modauto1 -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d classes/modauto1 --release 11 $(find ../src/modauto1 -name "*.java") 2>&1 +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d classes/modauto1 --release 25 $(find ../src/modauto1 -name "*.java") 2>&1 # Package modauto1 as JAR in amlib1/ (automatic module library directory) pushd classes/modauto1 > /dev/null 2>&1 echo "jar $JAR_OPTIONS --create --file=../../amlib1/modauto1.jar ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../amlib1/modauto1.jar" . 2>&1 +"${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../amlib1/modauto1.jar" . 2>&1 popd >/dev/null 2>&1 # Now compile explicit modules with Maven @@ -56,6 +43,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh index 4483dc8e..151bf229 100755 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh @@ -4,18 +4,6 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# IMPORTANT: This example MUST run with JDK 11 (not JDK 17) -# The expected output was created with JDK 11, and the available modules list -# differs between JDK 11 and JDK 17. -if [ -z "${JAVA11_HOME:-}" ] || [ "${JAVA11_HOME}" = "TODO/path/to/java11-jdk/goes/here" ]; then - echo "ERROR: This example requires JDK 11 to run (module list differs in JDK 17)" - echo "Please set JAVA11_HOME in .envrc or env.sh" - exit 1 -fi - -# Use JDK 11 for running (not the current JAVA_HOME which might be JDK 17) -export JAVA_HOME="${JAVA11_HOME}" - # Show Java version for user information echo "Using Java version:" "${JAVA_HOME}/bin/java" -version diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh index c8b99f30..1e931ca3 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh @@ -10,18 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Determine which Java to use for compilation -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -48,13 +36,13 @@ function compileandjar() { rm -rf ../m4/classes/"${mod}" mkdir -p ../m4/classes/"${mod}" - echo "javac ${JAVAC_OPTIONS} -d ../m4/classes/${mod} --release 11 \$(find ${mod} -name \"*.java\")" + echo "javac ${JAVAC_OPTIONS} -d ../m4/classes/${mod} --release 25 \$(find ${mod} -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS intentionally unquoted - "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/classes/"${mod}" --release 11 $(find "${mod}" -name "*.java") 2>&1 + "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/classes/"${mod}" --release 25 $(find "${mod}" -name "*.java") 2>&1 echo "jar ${JAR_OPTIONS} --create --file=../m4/${amlib}/${mod}.jar -C ../m4/classes/${mod} ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/"${amlib}"/"${mod}".jar -C ../m4/classes/"${mod}" . 2>&1 + "${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/"${amlib}"/"${mod}".jar -C ../m4/classes/"${mod}" . 2>&1 popd > /dev/null 2>&1 } @@ -69,7 +57,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package @@ -77,32 +65,32 @@ echo echo "Step 4: Manually compile modfoo (requires modauto1)" pushd ../src/modfoo > /dev/null 2>&1 mkdir -p ../../m4/mods/modfoo -echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modfoo --module-path ../../m4/target${PATH_SEPARATOR}../../m4/amlib1 --release 11 \$(find . -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modfoo --module-path ../../m4/target${PATH_SEPARATOR}../../m4/amlib1 --release 25 \$(find . -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS intentionally unquoted -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../../m4/mods/modfoo \ +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../../m4/mods/modfoo \ --module-path ../../m4/target"${PATH_SEPARATOR}"../../m4/amlib1 \ - --release 11 \ + --release 25 \ $(find . -name "*.java") 2>&1 echo "jar ${JAR_OPTIONS} --create --file=../../m4/target/modfoo.jar -C ../../m4/mods/modfoo ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/target/modfoo.jar -C ../../m4/mods/modfoo . 2>&1 +"${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/target/modfoo.jar -C ../../m4/mods/modfoo . 2>&1 popd >/dev/null 2>&1 echo echo "Step 5: Manually compile modbar (requires modauto2)" pushd ../src/modbar > /dev/null 2>&1 mkdir -p ../../m4/mods/modbar -echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modbar --module-path ../../m4/target${PATH_SEPARATOR}../../m4/amlib2 --release 11 \$(find . -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modbar --module-path ../../m4/target${PATH_SEPARATOR}../../m4/amlib2 --release 25 \$(find . -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS intentionally unquoted -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../../m4/mods/modbar \ +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../../m4/mods/modbar \ --module-path ../../m4/target"${PATH_SEPARATOR}"../../m4/amlib2 \ - --release 11 \ + --release 25 \ $(find . -name "*.java") 2>&1 echo "jar ${JAR_OPTIONS} --create --file=../../m4/target/modbar.jar -C ../../m4/mods/modbar ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/target/modbar.jar -C ../../m4/mods/modbar . 2>&1 +"${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/target/modbar.jar -C ../../m4/mods/modbar . 2>&1 popd >/dev/null 2>&1 echo diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh index be073806..e11789cb 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh @@ -4,18 +4,6 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# IMPORTANT: This example MUST run with JDK 11 (not JDK 17) -# The expected output was created with JDK 11, and the available modules list -# differs between JDK 11 and JDK 17. -if [ -z "${JAVA11_HOME:-}" ] || [ "${JAVA11_HOME}" = "TODO/path/to/java11-jdk/goes/here" ]; then - echo "ERROR: This example requires JDK 11 to run (module list differs in JDK 17)" - echo "Please set JAVA11_HOME in .envrc or env.sh" - exit 1 -fi - -# Use JDK 11 for running (not the current JAVA_HOME which might be JDK 17) -export JAVA_HOME="${JAVA11_HOME}" - # Show Java version for user information echo "Using Java version:" "${JAVA_HOME}/bin/java" -version diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh index 17bf2665..43dc0d3a 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -31,7 +24,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package # Copy Maven-built JARs to layer-specific directories for dynamic module loading @@ -56,19 +49,13 @@ echo echo "Compiling modcommon v2.0 from src2..." mkdir -p mods2 -# Reset JAVA_HOME to compilation JDK if needed -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - -echo "javac ${JAVAC_OPTIONS} -d mods2 --release 11 --module-version=2.0 --module-path target --module-source-path ../src2 \$(find ../src2/modcommon -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d mods2 --release 25 --module-version=2.0 --module-path target --module-source-path ../src2 \$(find ../src2/modcommon -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d mods2 --release 11 --module-version=2.0 --module-path target --module-source-path ../src2 $(find ../src2/modcommon -name "*.java") 2>&1 +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d mods2 --release 25 --module-version=2.0 --module-path target --module-source-path ../src2 $(find ../src2/modcommon -name "*.java") 2>&1 # Package new modcommon v2.0 as jar in barmlib (overwrites v1.0) pushd mods2 > /dev/null 2>&1 echo "jar $JAR_OPTIONS --create --file=../barmlib/modcommon.jar -C modcommon ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../barmlib/modcommon.jar" -C "modcommon" . 2>&1 +"${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../barmlib/modcommon.jar" -C "modcommon" . 2>&1 popd >/dev/null 2>&1 diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh index bede3efe..4d099e49 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh @@ -4,12 +4,9 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# Use JDK 11 for runtime to ensure successful verification -RUNTIME_JAVA_HOME="${JAVA11_HOME}" - # Show Java version for user information echo "Using Java version:" -"${RUNTIME_JAVA_HOME}/bin/java" -version +"${JAVA_HOME}/bin/java" -version echo # Create run-result directory if it doesn't exist @@ -33,4 +30,4 @@ fi # Run the Java code with "." argument for dynamic layer creation, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${RUNTIME_JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_naming-modules/m4/compile.sh b/jigsaw-examples/example_naming-modules/m4/compile.sh index b4e125ed..2680dcea 100755 --- a/jigsaw-examples/example_naming-modules/m4/compile.sh +++ b/jigsaw-examples/example_naming-modules/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -33,25 +26,19 @@ echo echo "Step 1: Compile automatic modules manually" echo -# Reset JAVA_HOME to compilation JDK if needed -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - # Compile automatic modules to separate amlib directories counter=0 for dir in automatic-whatever automatic-whateverX-47.11 automatic-whateverX48.12 automatic-whateverX49-13 do counter=$((counter+1)) - echo "javac ${JAVAC_OPTIONS} -d classes/${dir} --release 11 \$(find ../src/${dir} -name \"*.java\")" + echo "javac ${JAVAC_OPTIONS} -d classes/${dir} --release 25 \$(find ../src/${dir} -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded - "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d classes/${dir} --release 11 $(find ../src/${dir} -name "*.java") 2>&1 + "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d classes/${dir} --release 25 $(find ../src/${dir} -name "*.java") 2>&1 pushd classes/${dir} > /dev/null 2>&1 echo "jar $JAR_OPTIONS --create --file=../../amlib${counter}/${dir}.jar ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${COMPILE_JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../amlib${counter}/${dir}.jar" . 2>&1 + "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../amlib${counter}/${dir}.jar" . 2>&1 popd >/dev/null 2>&1 done @@ -65,7 +52,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_patch/m4/compile.sh b/jigsaw-examples/example_patch/m4/compile.sh index 51abae87..a8312d79 100755 --- a/jigsaw-examples/example_patch/m4/compile.sh +++ b/jigsaw-examples/example_patch/m4/compile.sh @@ -42,12 +42,12 @@ echo # --patch-module modb=src/modb-patch/main/java: Treats patch sources (via symlink) as part of modb # --module-path target/classes: Provides compiled modb classes for dependency resolution # -d patches/modb: Compile output to directory patches/modb -# --release 11: Target Java 11 (matching the main modules) +# --release 25: Target Java25 (matching the main modules) # Source file: src/modb-patch/main/java/pkgb/B.java (symlink → ../../../../src/modb-patch) echo "=== Step 3: Compile patch sources with javac ====" -echo "javac ${JAVAC_OPTIONS} --release 11 --patch-module modb=src/modb-patch/main/java --module-path target/classes -d patches/modb src/modb-patch/main/java/pkgb/B.java" +echo "javac ${JAVAC_OPTIONS} --release 25 --patch-module modb=src/modb-patch/main/java --module-path target/classes -d patches/modb src/modb-patch/main/java/pkgb/B.java" # shellcheck disable=SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} --release 11 --patch-module modb=src/modb-patch/main/java --module-path target/classes -d patches/modb src/modb-patch/main/java/pkgb/B.java 2>&1 +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} --release 25 --patch-module modb=src/modb-patch/main/java --module-path target/classes -d patches/modb src/modb-patch/main/java/pkgb/B.java 2>&1 echo echo "=== Step 4: Create patch JAR ====" diff --git a/jigsaw-examples/example_reflection/m4/compile.sh b/jigsaw-examples/example_reflection/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_reflection/m4/compile.sh +++ b/jigsaw-examples/example_reflection/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_requires-static/m4/compile.sh b/jigsaw-examples/example_requires-static/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_requires-static/m4/compile.sh +++ b/jigsaw-examples/example_requires-static/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_requires_exports-to/m4/compile.sh b/jigsaw-examples/example_requires_exports-to/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_requires_exports-to/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports-to/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_requires_exports/m4/compile.sh b/jigsaw-examples/example_requires_exports/m4/compile.sh index 37682871..e2b4aed4 100755 --- a/jigsaw-examples/example_requires_exports/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -25,5 +18,5 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_resolved-modules/m4/compile.sh b/jigsaw-examples/example_resolved-modules/m4/compile.sh index 13ffd537..7368097e 100755 --- a/jigsaw-examples/example_resolved-modules/m4/compile.sh +++ b/jigsaw-examples/example_resolved-modules/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -27,7 +20,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package # Copy JARs to mlib with simple names for jlink diff --git a/jigsaw-examples/example_resolved-modules/m4/run.sh b/jigsaw-examples/example_resolved-modules/m4/run.sh index 9b78e6c8..9e03729f 100755 --- a/jigsaw-examples/example_resolved-modules/m4/run.sh +++ b/jigsaw-examples/example_resolved-modules/m4/run.sh @@ -4,18 +4,6 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# IMPORTANT: This example MUST run with JDK 11 (not JDK 17) -# The expected output was created with JDK 11, and the available modules list -# differs between JDK 11 and JDK 17. -if [ -z "${JAVA11_HOME:-}" ] || [ "${JAVA11_HOME}" = "TODO/path/to/java11-jdk/goes/here" ]; then - echo "ERROR: This example requires JDK 11 to run (module list differs in JDK 17)" - echo "Please set JAVA11_HOME in .envrc or env.sh" - exit 1 -fi - -# Use JDK 11 for running (not the current JAVA_HOME which might be JDK 17) -export JAVA_HOME="${JAVA11_HOME}" - result_dir="${1:-run-result}" rm -rf "${result_dir}" diff --git a/jigsaw-examples/example_resources/m4/compile.sh b/jigsaw-examples/example_resources/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_resources/m4/compile.sh +++ b/jigsaw-examples/example_resources/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_splitpackage/m4/compile.sh b/jigsaw-examples/example_splitpackage/m4/compile.sh index 5a8ae38d..106b255e 100755 --- a/jigsaw-examples/example_splitpackage/m4/compile.sh +++ b/jigsaw-examples/example_splitpackage/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -27,6 +20,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh b/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh index 9d417352..0965f9b1 100755 --- a/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh +++ b/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh @@ -10,19 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Determine which Java to use for compilation -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -48,13 +35,13 @@ function compileandjar() { rm -rf ../m4/"${classes}" mkdir -p ../m4/"${classes}" - echo "javac ${JAVAC_OPTIONS} -d ../m4/${classes} --release 11 \$(find ${modauto} -name \"*.java\")" + echo "javac ${JAVAC_OPTIONS} -d ../m4/${classes} --release 25 \$(find ${modauto} -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS intentionally unquoted - "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/"${classes}" --release 11 $(find "${modauto}" -name "*.java") 2>&1 + "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/"${classes}" --release 25 $(find "${modauto}" -name "*.java") 2>&1 echo "jar ${JAR_OPTIONS} --create --file=../m4/${amlib}/${modauto}.jar -C ../m4/${classes} ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/"${amlib}"/"${modauto}".jar -C ../m4/"${classes}" . 2>&1 + "${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/"${amlib}"/"${modauto}".jar -C ../m4/"${classes}" . 2>&1 popd > /dev/null 2>&1 } @@ -69,7 +56,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" echo "(Compiler args: --module-path amlib1)" mvn clean package diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh b/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh index 4719ac32..ecedd527 100755 --- a/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh +++ b/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh @@ -4,18 +4,6 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# IMPORTANT: This example MUST run with JDK 11 (not JDK 17) -# The expected output was created with JDK 11, and the available modules list -# differs between JDK 11 and JDK 17. -if [ -z "${JAVA11_HOME:-}" ] || [ "${JAVA11_HOME}" = "TODO/path/to/java11-jdk/goes/here" ]; then - echo "ERROR: This example requires JDK 11 to run (module list differs in JDK 17)" - echo "Please set JAVA11_HOME in .envrc or env.sh" - exit 1 -fi - -# Use JDK 11 for running (not the current JAVA_HOME which might be JDK 17) -export JAVA_HOME="${JAVA11_HOME}" - # Show Java version for user information echo "Using Java version:" "${JAVA_HOME}/bin/java" -version diff --git a/jigsaw-examples/example_test/m4/compile-whiteboxtest.sh b/jigsaw-examples/example_test/m4/compile-whiteboxtest.sh index 038ebbf5..9e324dbe 100755 --- a/jigsaw-examples/example_test/m4/compile-whiteboxtest.sh +++ b/jigsaw-examples/example_test/m4/compile-whiteboxtest.sh @@ -10,11 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -MAVEN_JAVA_HOME="${JAVA17_HOME:-${JAVA_HOME}}" - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -24,13 +19,13 @@ mkdir -p patchlib echo "=== Step 1: Show Maven version ===" echo "mvn --version" -JAVA_HOME="${MAVEN_JAVA_HOME}" mvn --version +JAVA_HOME="${JAVA_HOME}" mvn --version echo echo "=== Step 2: Compile modfib with Maven and download JUnit ===" echo "mvn clean test-compile" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -JAVA_HOME="${MAVEN_JAVA_HOME}" mvn clean test-compile +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" +JAVA_HOME="${JAVA_HOME}" mvn clean test-compile echo # Create modfib JAR @@ -47,7 +42,7 @@ popd >/dev/null 2>&1 echo # Prepare dependencies for whitebox test -JAVA_HOME="${MAVEN_JAVA_HOME}" mvn dependency:copy-dependencies -DoutputDirectory=amlib -DincludeScope=test +JAVA_HOME="${JAVA_HOME}" mvn dependency:copy-dependencies -DoutputDirectory=amlib -DincludeScope=test # Package whitebox test JAR echo "jar ${JAR_OPTIONS} --create --file=patchlib/modfib.jar -C target/test-classes/modfib ." diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh index 8ea4aeb8..68a792e7 100755 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh @@ -10,19 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Determine which Java to use for compilation -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -37,7 +24,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package @@ -46,17 +33,17 @@ echo "Step 3: Manually compile classpath code (cpmain)" # Compile cpmain (classpath code) with access to modules in mlib pushd ../src > /dev/null 2>&1 -echo "javac ${JAVAC_OPTIONS} -cp ../m4/mlib/*${PATH_SEPARATOR} -d ../m4/classes/cpmain --release 11 \$(find cpmain -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -cp ../m4/mlib/*${PATH_SEPARATOR} -d ../m4/classes/cpmain --release 25 \$(find cpmain -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS and PATH_SEPARATOR intentionally unquoted -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} \ +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} \ -cp ../m4/mlib/*${PATH_SEPARATOR} \ - -d ../m4/classes/cpmain --release 11 \ + -d ../m4/classes/cpmain --release 25 \ $(find cpmain -name "*.java") 2>&1 # Package cpmain as JAR in cplib/ echo "jar ${JAR_OPTIONS} --create --file=../m4/cplib/cpmain.jar -C ../m4/classes/cpmain ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/cplib/cpmain.jar -C ../m4/classes/cpmain . 2>&1 +"${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/cplib/cpmain.jar -C ../m4/classes/cpmain . 2>&1 popd >/dev/null 2>&1 echo diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh index ded6852c..2cd17003 100755 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh @@ -4,19 +4,6 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# IMPORTANT: This example MUST run with JDK 11 (not JDK 17) -# The --illegal-access flag was removed in JDK 17, but this example tests -# the --illegal-access=permit DEFAULT behavior of JDK 9-16. -# Variant 6-8 expect to work because --illegal-access=permit is the default in JDK 11. -if [ -z "${JAVA11_HOME:-}" ] || [ "${JAVA11_HOME}" = "TODO/path/to/java11-jdk/goes/here" ]; then - echo "ERROR: This example requires JDK 11 to run (--illegal-access flag was removed in JDK 17)" - echo "Please set JAVA11_HOME in .envrc or env.sh" - exit 1 -fi - -# Use JDK 11 for running (not the current JAVA_HOME which might be JDK 17) -export JAVA_HOME="${JAVA11_HOME}" - result_dir="${1:-run-result}" rm -rf "${result_dir}" diff --git a/jigsaw-examples/example_unnamed-module_access-from-automatic-module/m4/compile.sh b/jigsaw-examples/example_unnamed-module_access-from-automatic-module/m4/compile.sh index 62c44b14..5c583d18 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-automatic-module/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-automatic-module/m4/compile.sh @@ -16,37 +16,31 @@ mkdir -p classes echo "=== Manual compilation (no Maven - no explicit modules) ===" echo -# Reset JAVA_HOME to compilation JDK if needed -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - # Step 1: Compile classpath code (cpa) first echo "Step 1: Compile classpath code (cpa)" pushd ../src > /dev/null 2>&1 dir=cpa -echo "javac ${JAVAC_OPTIONS} -d ../m4/classes/${dir} --release 11 \$(find ${dir} -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d ../m4/classes/${dir} --release 25 \$(find ${dir} -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/classes/${dir} --release 11 $(find ${dir} -name "*.java") 2>&1 +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/classes/${dir} --release 25 $(find ${dir} -name "*.java") 2>&1 echo "jar $JAR_OPTIONS --create --file=../m4/cplib/${dir}.jar -C ../m4/classes/${dir} ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../m4/cplib/${dir}.jar" -C "../m4/classes/${dir}" . 2>&1 +"${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../m4/cplib/${dir}.jar" -C "../m4/classes/${dir}" . 2>&1 echo # Step 2: Compile automatic module (modmain.auto) with access to classpath echo "Step 2: Compile automatic module (modmain.auto)" dir=modmain.auto -echo "javac ${JAVAC_OPTIONS} -cp ../m4/cplib/* -d ../m4/classes/${dir} --release 11 \$(find ${dir} -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -cp ../m4/cplib/* -d ../m4/classes/${dir} --release 25 \$(find ${dir} -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -cp ../m4/cplib/* -d ../m4/classes/${dir} --release 11 $(find ${dir} -name "*.java") 2>&1 +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -cp ../m4/cplib/* -d ../m4/classes/${dir} --release 25 $(find ${dir} -name "*.java") 2>&1 echo "jar $JAR_OPTIONS --create --file=../m4/amlib/${dir}.jar -C ../m4/classes/${dir} ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../m4/amlib/${dir}.jar" -C "../m4/classes/${dir}" . 2>&1 +"${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../m4/amlib/${dir}.jar" -C "../m4/classes/${dir}" . 2>&1 popd >/dev/null 2>&1 diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh index 0253fa35..bdd91ea7 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh @@ -10,19 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Determine which Java to use for compilation -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -35,14 +22,14 @@ echo "Step 1: Manually compile classpath code (cpb)" # Compile cpb (classpath code) manually pushd ../src > /dev/null 2>&1 -echo "javac ${JAVAC_OPTIONS} -d ../m4/classes/cpb --release 11 \$(find cpb -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d ../m4/classes/cpb --release 25 \$(find cpb -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS intentionally unquoted -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/classes/cpb --release 11 $(find cpb -name "*.java") 2>&1 +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../m4/classes/cpb --release 25 $(find cpb -name "*.java") 2>&1 # Package cpb as JAR in cplib/ echo "jar ${JAR_OPTIONS} --create --file=../m4/cplib/cpb.jar -C ../m4/classes/cpb ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/cplib/cpb.jar -C ../m4/classes/cpb . 2>&1 +"${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../m4/cplib/cpb.jar -C ../m4/classes/cpb . 2>&1 popd >/dev/null 2>&1 echo @@ -52,7 +39,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" echo "(Compiler args: --add-reads modmain=ALL-UNNAMED --class-path cplib/cpb.jar)" mvn clean package diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh index dc432336..2e6bc821 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -29,21 +22,15 @@ echo echo "Step 1: Compile classpath code (cpb) manually" echo -# Reset JAVA_HOME to compilation JDK if needed -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - -echo "javac ${JAVAC_OPTIONS} -d classes --release 11 \$(find ../src/cpb -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d classes --release 25 \$(find ../src/cpb -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d classes --release 11 $(find ../src/cpb -name "*.java") 2>&1 +"${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d classes --release 25 $(find ../src/cpb -name "*.java") 2>&1 # Package cpb as JAR in cplib/ (classpath library directory) pushd classes > /dev/null 2>&1 echo "jar $JAR_OPTIONS --create --file=../cplib/cpb.jar ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../cplib/cpb.jar" . 2>&1 +"${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../cplib/cpb.jar" . 2>&1 popd >/dev/null 2>&1 # Now compile modules with Maven @@ -56,7 +43,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" echo "(Modules can access cpb on classpath via --add-reads modmain=ALL-UNNAMED)" mvn clean package diff --git a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh index 44525812..1ec32336 100755 --- a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -33,7 +26,7 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package # Step 2: Compile classpath code (cpb, cpmain) manually @@ -42,22 +35,16 @@ echo echo "Step 2: Compile classpath code (cpb, cpmain) manually" echo -# Reset JAVA_HOME to compilation JDK if needed -COMPILE_JAVA_HOME="${JAVA_HOME}" -if [ -n "${JAVA11_HOME:-}" ] && [ "${JAVA11_HOME}" != "TODO/path/to/java11-jdk/goes/here" ]; then - COMPILE_JAVA_HOME="${JAVA11_HOME}" -fi - # Compile classpath code in correct order: cpb first, then cpmain (which depends on cpb) pushd ../src > /dev/null 2>&1 for dir in cpb cpmain; do - echo "javac ${JAVAC_OPTIONS} -cp ../m4/target/*${PATH_SEPARATOR}../m4/classes/cpb -d ../m4/classes/${dir} --release 11 \$(find ${dir} -name \"*.java\")" + echo "javac ${JAVAC_OPTIONS} -cp ../m4/target/*${PATH_SEPARATOR}../m4/classes/cpb -d ../m4/classes/${dir} --release 25 \$(find ${dir} -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded - "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -cp ../m4/target/*"${PATH_SEPARATOR}"../m4/classes/cpb -d ../m4/classes/${dir} --release 11 $(find ${dir} -name "*.java") 2>&1 + "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -cp ../m4/target/*"${PATH_SEPARATOR}"../m4/classes/cpb -d ../m4/classes/${dir} --release 25 $(find ${dir} -name "*.java") 2>&1 echo "jar $JAR_OPTIONS --create --file=../m4/cplib/${dir}.jar -C ../m4/classes/${dir} ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${COMPILE_JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../m4/cplib/${dir}.jar" -C "../m4/classes/${dir}" . 2>&1 + "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../m4/cplib/${dir}.jar" -C "../m4/classes/${dir}" . 2>&1 done popd >/dev/null 2>&1 diff --git a/jigsaw-examples/example_uses-provides/m4/compile.sh b/jigsaw-examples/example_uses-provides/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_uses-provides/m4/compile.sh +++ b/jigsaw-examples/example_uses-provides/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh b/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh +++ b/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_version/m4/compile.sh b/jigsaw-examples/example_version/m4/compile.sh index 3d6b7cb8..d1cf426e 100755 --- a/jigsaw-examples/example_version/m4/compile.sh +++ b/jigsaw-examples/example_version/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml has 11 which ensures -# Java 11 compatible bytecode even when using JDK 17 compiler with --release 11 -if [ -n "${JAVA17_HOME:-}" ]; then - export JAVA_HOME="${JAVA17_HOME}" -fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" @@ -26,6 +19,6 @@ mvn --version echo echo "mvn clean package" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17+, compiles for Java 25 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_version/m4/run.sh b/jigsaw-examples/example_version/m4/run.sh index f7f36bc5..fa508d91 100755 --- a/jigsaw-examples/example_version/m4/run.sh +++ b/jigsaw-examples/example_version/m4/run.sh @@ -4,12 +4,9 @@ set -eu -o pipefail # shellcheck source=../../env.sh source ../../env.sh -# Use JDK 11 for runtime to demonstrate JDK 11 version strings -RUNTIME_JAVA_HOME="${JAVA11_HOME}" - # Show Java version for user information echo "Using Java version:" -"${RUNTIME_JAVA_HOME}/bin/java" -version +"${JAVA_HOME}/bin/java" -version echo # Create run-result directory if it doesn't exist @@ -17,4 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${RUNTIME_JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho From 54e37b7511a95712a48a452a7e0b20fd22245c23 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Wed, 31 Dec 2025 14:36:27 +0100 Subject: [PATCH 4/5] Finalize switch to JDK 25 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove support for JDK 11 and JDK 17, keeping only JDK 25 (default) and JDK 8 (for cross-compilation example). Changes: - GitHub Actions: Remove JDK 11/17 from CI matrix, use JDK 25 only - Gradle example: Update JAVA_HOME references for JDK 25 compatibility - Regenerate expected-result files for JDK 25 module lists - Root README: Document JDK 25 migration and --illegal-access removal Illegal-access example (JEP 403 compliance): - Remove --illegal-access variants (flag removed in Java 17) - Variants removed: 2-4, 6-9, 11-14, 17-19 - Keep only variants demonstrating current JDK 17+ behavior: - Without options: InaccessibleObjectException (variants 1, 16) - With --add-opens: Permitted access (variants 5, 10, 15, 20) - Update run.sh and m4/run.sh with consistent documentation - Document changes in example README.adoc 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/build.yml | 76 +++------- README.adoc | 16 ++- .../example_addExports_manifest/m4/compile.sh | 7 - .../example_addExports_manifest/m4/pom.xml | 3 - .../example_gradle-project/clean.sh | 3 +- .../example_gradle-project/compile.sh | 3 +- .../example_gradle-project/run-test.sh | 3 +- jigsaw-examples/example_gradle-project/run.sh | 3 +- .../expected-result/run.txt | 16 ++- .../expected-result/run.txt | 12 +- .../expected-result/run.txt | 4 +- .../expected-result/run.txt | 8 +- .../expected-result/run.txt | 13 +- .../expected-result/run.txt | 4 +- .../README.adoc | 29 +++- .../expected-result/run.txt | 45 ------ .../m4/run.sh | 132 +++--------------- .../run.sh | 132 +++--------------- .../example_version/expected-result/run.txt | 12 +- 19 files changed, 147 insertions(+), 374 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6988b2f9..1b733442 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,8 +56,8 @@ jobs: distribution: 'zulu' java-version: '8' - - name: Set up JDK 25 - id: setup-jdk25 + - name: Set up JDK + id: setup-jdk uses: actions/setup-java@v5 with: distribution: 'temurin' @@ -65,36 +65,24 @@ jobs: java-version: '25.0.1' # end::java-version-minimal[] - - name: Set up JDK 17 - id: setup-jdk17 - uses: actions/setup-java@v5 - with: - distribution: 'temurin' - java-version: '17' - - name: Create .envrc with Java paths shell: bash env: JAVA8_PATH: ${{ steps.setup-jdk8.outputs.path || steps.setup-jdk8-mac.outputs.path }} - JAVA25_PATH: ${{ steps.setup-jdk25.outputs.path }} - JAVA17_PATH: ${{ steps.setup-jdk17.outputs.path }} + JAVA_PATH: ${{ steps.setup-jdk.outputs.path }} run: | # Convert Windows paths to Unix paths if on Windows if [[ "$RUNNER_OS" == "Windows" ]]; then JAVA8_PATH="$(cygpath -u "$JAVA8_PATH")" - JAVA25_PATH="$(cygpath -u "$JAVA25_PATH")" - JAVA17_PATH="$(cygpath -u "$JAVA17_PATH")" + JAVA_PATH="$(cygpath -u "$JAVA_PATH")" fi cat > .envrc << EOF # Environment configuration for Java 9 Jigsaw Examples # Auto-generated by GitHub Actions - # Path to JDK 17 or later (required for example_gradle-project with Gradle 9.x) - export JAVA17_HOME=$JAVA17_PATH - - # Path to JDK 11 (required for most examples, JDK 17 is also fine) - export JAVA_HOME=$JAVA25_PATH + # Path to JDK + export JAVA_HOME=$JAVA_PATH # Path to JDK 8 (only needed for example_compile-target-jdk8) export JAVA8_HOME=$JAVA8_PATH @@ -119,16 +107,10 @@ jobs: echo "✓ JDK 8 is available at: $JAVA8_HOME" echo "" - echo "=== Verifying JDK 11 ===" + echo "=== Verifying JDK ===" PATH="$JAVA_HOME/bin:$PATH" java -version - echo "✓ JDK 11 is available at: $JAVA_HOME" - - echo "" - echo "=== Verifying JDK 17 ===" - PATH="$JAVA17_HOME/bin:$PATH" - java -version - echo "✓ JDK 17 is available at: $JAVA17_HOME" + echo "✓ JDK is available at: $JAVA_HOME" - name: Compile all Samples shell: bash @@ -190,20 +172,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 - - name: Set up JDK 25 - id: setup-jdk25 + - name: Set up JDK + id: setup-jdk uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '25.0.1' - - name: Set up JDK 17 - id: setup-jdk17 - uses: actions/setup-java@v5 - with: - distribution: 'temurin' - java-version: '17' - - name: Set up Maven 4 uses: stCarolas/setup-maven@v5 with: @@ -214,8 +189,7 @@ jobs: - name: Create .envrc with Java and Maven paths shell: bash env: - JAVA25_PATH: ${{ steps.setup-jdk25.outputs.path }} - JAVA17_PATH: ${{ steps.setup-jdk17.outputs.path }} + JAVA_PATH: ${{ steps.setup-jdk.outputs.path }} run: | # Detect Maven home if command -v mvn > /dev/null; then @@ -233,8 +207,7 @@ jobs: # Convert Windows paths to Unix paths if on Windows if [[ "$RUNNER_OS" == "Windows" ]]; then - JAVA25_PATH="$(cygpath -u "$JAVA25_PATH")" - JAVA17_PATH="$(cygpath -u "$JAVA17_PATH")" + JAVA_PATH="$(cygpath -u "$JAVA_PATH")" MAVEN4_PATH="$(cygpath -u "$MAVEN4_PATH")" fi @@ -242,14 +215,8 @@ jobs: # Environment configuration for Java 9 Jigsaw Examples (Maven 4 builds) # Auto-generated by GitHub Actions - # Path to JDK 17 (default for Maven 4 builds) - export JAVA17_HOME=$JAVA17_PATH - - # Path to JDK 17 is the default JAVA_HOME for Maven 4 - export JAVA_HOME=$JAVA17_PATH - - # Path to JDK 11 (for compatibility with examples that need it) - export JAVA11_HOME=$JAVA25_PATH + # Path to JDK is the default JAVA_HOME + export JAVA_HOME=$JAVA_PATH # Path to Maven 4 (required for m4 builds) export M4_HOME=$MAVEN4_PATH @@ -268,17 +235,10 @@ jobs: source .envrc - echo "=== Verifying JDK 17 (default) ===" + echo "=== Verifying JDK (default) ===" PATH="$JAVA_HOME/bin:$PATH" java -version - echo "✓ JDK 17 is available at: $JAVA_HOME" - echo "✓ JDK 17 is also at: $JAVA17_HOME" - - echo "" - echo "=== Verifying JDK 11 (compatibility) ===" - PATH="$JAVA11_HOME/bin:$PATH" - java -version - echo "✓ JDK 11 is available at: $JAVA11_HOME" + echo "✓ JDK is available at: $JAVA_HOME" echo "" echo "=== Verifying Maven 4 ===" @@ -349,11 +309,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 - - name: Set up JDK 17 + - name: Set up JDK uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '17' + java-version: '25.0.1' - name: Download Linux legacy run results for documentation uses: actions/download-artifact@v4 diff --git a/README.adoc b/README.adoc index c13dbbc5..beff35a6 100755 --- a/README.adoc +++ b/README.adoc @@ -429,9 +429,23 @@ No software is ready, ever ;-) So here are some ideas left (any other feedback v * [ ] New example for test coverage when doing whitebox tests * [ ] Known issues: + +[[note:jdk-25-migration]] [NOTE] +.JDK 25 Migration ==== -All examples work with current Java LTS versions (11, 17). +All examples have been migrated to JDK 25 (see <>). +JDK 11 and 17 support has been removed from CI. + +*JDK 17+ breaking change - `--illegal-access` removed:* +The `--illegal-access` flag was removed in Java 17 (https://openjdk.org/jeps/403[JEP 403]). +The xref:jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc[example_unnamed-module-reflection-illegal-access] has been updated accordingly: +test variants using `--illegal-access=permit/warn/deny` were removed, leaving only variants demonstrating the two behaviors available in JDK 17+: + +. Without options: Reflective access to non-exported packages throws `InaccessibleObjectException` +. With explicit `--add-opens`: Reflective access is permitted + +See the xref:jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc#note:jdk_17_compatibility_changes[example's JDK 17+ Compatibility Changes] note for details. + The xref:jigsaw-examples/example_spring-hibernate/README.adoc[example_spring-hibernate] may need updates for optimal Java 17+ compatibility. ==== diff --git a/jigsaw-examples/example_addExports_manifest/m4/compile.sh b/jigsaw-examples/example_addExports_manifest/m4/compile.sh index a2955e9e..c0ea994d 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/compile.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/compile.sh @@ -10,13 +10,6 @@ if [ -z "${M4_HOME:-}" ]; then exit 1 fi -# Maven 4 requires Java 17+ to run -# Note: pom.xml uses source/target (not release) because --add-exports java.base -# is incompatible with --release flag -#if [ -n "${JAVA17_HOME:-}" ]; then -# export JAVA_HOME="${JAVA17_HOME}" -#fi - # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" diff --git a/jigsaw-examples/example_addExports_manifest/m4/pom.xml b/jigsaw-examples/example_addExports_manifest/m4/pom.xml index 6cd73e3a..ebc2d6a9 100644 --- a/jigsaw-examples/example_addExports_manifest/m4/pom.xml +++ b/jigsaw-examples/example_addExports_manifest/m4/pom.xml @@ -32,9 +32,6 @@ 4.0.0-beta-3 - - --system - ${env.JAVA11_HOME} --add-exports java.base/jdk.internal.org.xml.sax=modmain diff --git a/jigsaw-examples/example_gradle-project/clean.sh b/jigsaw-examples/example_gradle-project/clean.sh index 256e764e..812d3637 100755 --- a/jigsaw-examples/example_gradle-project/clean.sh +++ b/jigsaw-examples/example_gradle-project/clean.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash source ../env.sh -PATH="${JAVA17_HOME}/bin:$PATH" -JAVA_HOME=${JAVA17_HOME} +PATH="${JAVA_HOME}/bin:$PATH" ./gradlew --version ./gradlew --info --stacktrace --no-daemon clean 2>&1 diff --git a/jigsaw-examples/example_gradle-project/compile.sh b/jigsaw-examples/example_gradle-project/compile.sh index 2f7a5bab..5b7cf21c 100755 --- a/jigsaw-examples/example_gradle-project/compile.sh +++ b/jigsaw-examples/example_gradle-project/compile.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash source ../env.sh -PATH="${JAVA17_HOME}/bin:$PATH" -JAVA_HOME=${JAVA17_HOME} +PATH="${JAVA_HOME}/bin:$PATH" ./gradlew --version ./gradlew --info --stacktrace --no-daemon build 2>&1 diff --git a/jigsaw-examples/example_gradle-project/run-test.sh b/jigsaw-examples/example_gradle-project/run-test.sh index 9b7c8246..4d4a3e28 100755 --- a/jigsaw-examples/example_gradle-project/run-test.sh +++ b/jigsaw-examples/example_gradle-project/run-test.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash source ../env.sh -PATH="${JAVA17_HOME}/bin:$PATH" -JAVA_HOME=${JAVA17_HOME} +PATH="${JAVA_HOME}/bin:$PATH" ./gradlew --version ./gradlew --info --stacktrace --no-daemon test 2>&1 diff --git a/jigsaw-examples/example_gradle-project/run.sh b/jigsaw-examples/example_gradle-project/run.sh index c3470a4b..a2a24c20 100755 --- a/jigsaw-examples/example_gradle-project/run.sh +++ b/jigsaw-examples/example_gradle-project/run.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash source ../env.sh -PATH="${JAVA17_HOME}/bin:$PATH" -JAVA_HOME=${JAVA17_HOME} +PATH="${JAVA_HOME}/bin:$PATH" ./gradlew --version ./gradlew --info --stacktrace --no-daemon run 2>&1 diff --git a/jigsaw-examples/example_layer-hierarchy/expected-result/run.txt b/jigsaw-examples/example_layer-hierarchy/expected-result/run.txt index e9bbf63b..0596b260 100644 --- a/jigsaw-examples/example_layer-hierarchy/expected-result/run.txt +++ b/jigsaw-examples/example_layer-hierarchy/expected-result/run.txt @@ -1,4 +1,4 @@ -Layer 'boot' on level 'root' (java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, javax.json, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, mod.layer, mod.main) +Layer 'boot' on level 'root' (java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, javax.json, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, mod.layer, mod.main) Contains these modules: module java.base module java.compiler @@ -16,16 +16,26 @@ Contains these modules: module java.xml module java.xml.crypto module javax.json + module jdk.attach module jdk.charsets module jdk.compiler module jdk.crypto.cryptoki - module jdk.crypto.ec + module jdk.editpad + module jdk.internal.ed + module jdk.internal.jvmstat + module jdk.internal.le + module jdk.internal.md module jdk.internal.opt module jdk.jartool module jdk.javadoc module jdk.jdeps + module jdk.jdi + module jdk.jdwp.agent module jdk.jfr module jdk.jlink + module jdk.jpackage + module jdk.jshell + module jdk.jstatd module jdk.localedata module jdk.management module jdk.management.jfr @@ -38,7 +48,7 @@ Contains these modules: module mod.layer module mod.main Layer 'toplayer' on level 'top' (mod.u_bottom_middle_top, mod.x_top, mod.y_top, mod.z_top, mod.zreverse_bottom, mod.zreverse_middle, mod.zreverse_top) -Parent 'boot' on level 'root' (java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, javax.json, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, mod.layer, mod.main) +Parent 'boot' on level 'root' (java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, javax.json, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, mod.layer, mod.main) Contains these modules: module mod.u_bottom_middle_top module mod.x_top diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/expected-result/run.txt b/jigsaw-examples/example_layer-modules-all-in-boot-layer/expected-result/run.txt index d60e6021..162f161d 100644 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/expected-result/run.txt +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/expected-result/run.txt @@ -2,18 +2,18 @@ Infos for Layer and Module which contain pkgmain.Main, id=ID_Main_13 Layer (java.lang.ModuleLayer), boot layer Layer's parents: none, as this is the boot layer Layer's list of modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain Layer's configuration with its list of resolved modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain Reflective call to pkgfoo.Foo in modfoo in current boot layer... Infos for Layer and Module which contain pkgfoo.Foo, id=ID_Main_51, using automatic module version V1 Layer (java.lang.ModuleLayer), boot layer Layer's parents: none, as this is the boot layer Layer's list of modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain Layer's configuration with its list of resolved modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain pkgfoo.Foo, id=ID_Main_51, using automatic module version V1 Reflective call to pkgbar.Bar in modbar in current boot layer... @@ -21,7 +21,7 @@ Infos for Layer and Module which contain pkgbar.Bar, id=ID_Main_51, using automa Layer (java.lang.ModuleLayer), boot layer Layer's parents: none, as this is the boot layer Layer's list of modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain Layer's configuration with its list of resolved modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modbar, modcommon, modfoo, modmain pkgbar.Bar, id=ID_Main_51, using automatic module version V1 diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/expected-result/run.txt b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/expected-result/run.txt index c4af42dc..0e38459d 100644 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/expected-result/run.txt +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/expected-result/run.txt @@ -2,9 +2,9 @@ Infos for Layer and Module which contain pkgmain.Main, id=ID_Main_19 Layer (java.lang.ModuleLayer), boot layer Layer's parents: none, as this is the boot layer Layer's list of modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modcommon, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modcommon, modmain Layer's configuration with its list of resolved modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modcommon, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modcommon, modmain Create a new 'foo layer #1' as a child of the current layer... Reflective call to pkgfoo.Foo in modfoo in 'foo layer #1'... diff --git a/jigsaw-examples/example_layer-modules-module-resolution/expected-result/run.txt b/jigsaw-examples/example_layer-modules-module-resolution/expected-result/run.txt index 3e3a7050..57993336 100644 --- a/jigsaw-examples/example_layer-modules-module-resolution/expected-result/run.txt +++ b/jigsaw-examples/example_layer-modules-module-resolution/expected-result/run.txt @@ -2,7 +2,7 @@ Infos for Layer and Module: Layer (ModuleLayer), boot layer Layer's parents: none, as this is the boot layer Layer's configuration including read dependencies: -java.base@11.0.28 (Configuration) -> [], java.compiler@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration)], java.datatransfer@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration)], java.desktop@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.datatransfer@11.0.28 (Configuration), java.prefs@11.0.28 (Configuration), java.xml@11.0.28 (Configuration)], java.logging@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration)], java.management.rmi@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.management@11.0.28 (Configuration), java.naming@11.0.28 (Configuration), java.rmi@11.0.28 (Configuration)], java.management@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration)], java.naming@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.security.sasl@11.0.28 (Configuration)], java.prefs@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.xml@11.0.28 (Configuration)], java.rmi@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.logging@11.0.28 (Configuration)], java.security.jgss@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.naming@11.0.28 (Configuration)], java.security.sasl@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.logging@11.0.28 (Configuration)], java.smartcardio@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration)], java.xml.crypto@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration), java.logging@11.0.28 (Configuration), java.xml@11.0.28 (Configuration)], java.xml@11.0.28 (Configuration) -> [java.base@11.0.28 (Configuration)], modcommon@1.0 (Configuration) -> [java.base@11.0.28 (Configuration)], modmain@1.0 (Configuration) -> [java.base@11.0.28 (Configuration), modcommon@1.0 (Configuration)] +java.base@25.0.1 (Configuration) -> [], java.compiler@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration)], java.datatransfer@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration)], java.desktop@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.datatransfer@25.0.1 (Configuration), java.prefs@25.0.1 (Configuration), java.xml@25.0.1 (Configuration)], java.logging@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration)], java.management.rmi@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.management@25.0.1 (Configuration), java.naming@25.0.1 (Configuration), java.rmi@25.0.1 (Configuration)], java.management@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration)], java.naming@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.security.sasl@25.0.1 (Configuration)], java.prefs@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.xml@25.0.1 (Configuration)], java.rmi@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.logging@25.0.1 (Configuration)], java.security.jgss@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.naming@25.0.1 (Configuration)], java.security.sasl@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.logging@25.0.1 (Configuration)], java.smartcardio@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration)], java.xml.crypto@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration), java.logging@25.0.1 (Configuration), java.xml@25.0.1 (Configuration)], java.xml@25.0.1 (Configuration) -> [java.base@25.0.1 (Configuration)], modcommon@1.0 (Configuration) -> [java.base@25.0.1 (Configuration)], modmain@1.0 (Configuration) -> [java.base@25.0.1 (Configuration), modcommon@1.0 (Configuration)] Create a new 'foo layer #1' as a child of the current layer... Reflective call to pkgfoo.Foo in modfoo in 'foo layer #1'... @@ -10,7 +10,7 @@ Infos for Layer and Module: Layer (ModuleLayer), not boot layer Layer's parents: Parent is boot layer Layer's configuration including read dependencies: -modfoo@1.0 (Configuration) -> [java.base@11.0.28 (Configuration), modcommon@1.0 (Configuration), modversion1@1.0 (Configuration)], modversion1@1.0 (Configuration) -> [java.base@11.0.28 (Configuration)] +modfoo@1.0 (Configuration) -> [java.base@25.0.1 (Configuration), modcommon@1.0 (Configuration), modversion1@1.0 (Configuration)], modversion1@1.0 (Configuration) -> [java.base@25.0.1 (Configuration)] pkgfoo.Foo, id=ID_Main_74, using automatic module version V1 Create a new 'bar layer #1' as a child of the current layer... @@ -19,7 +19,7 @@ Infos for Layer and Module: Layer (ModuleLayer), not boot layer Layer's parents: Parent is boot layer Layer's configuration including read dependencies: -modbar@1.0 (Configuration) -> [java.base@11.0.28 (Configuration), modcommon@1.0 (Configuration), modversion2@1.0 (Configuration)], modversion2@1.0 (Configuration) -> [java.base@11.0.28 (Configuration)] +modbar@1.0 (Configuration) -> [java.base@25.0.1 (Configuration), modcommon@1.0 (Configuration), modversion2@1.0 (Configuration)], modversion2@1.0 (Configuration) -> [java.base@25.0.1 (Configuration)] pkgbar.Bar, id=ID_Main_74, using automatic module version V2 Create a new 'bar layer #2' as a child of the current layer... @@ -28,5 +28,5 @@ Infos for Layer and Module: Layer (ModuleLayer), not boot layer Layer's parents: Parent is boot layer Layer's configuration including read dependencies: -modbar@1.0 (Configuration) -> [java.base@11.0.28 (Configuration), modcommon@2.0 (Configuration), modversion2@1.0 (Configuration)], modcommon@2.0 (Configuration) -> [java.base@11.0.28 (Configuration)], modversion2@1.0 (Configuration) -> [java.base@11.0.28 (Configuration)] +modbar@1.0 (Configuration) -> [java.base@25.0.1 (Configuration), modcommon@2.0 (Configuration), modversion2@1.0 (Configuration)], modcommon@2.0 (Configuration) -> [java.base@25.0.1 (Configuration)], modversion2@1.0 (Configuration) -> [java.base@25.0.1 (Configuration)] pkgbar.Bar, id=ID_Main_74, using automatic module version V2 diff --git a/jigsaw-examples/example_resolved-modules/expected-result/run.txt b/jigsaw-examples/example_resolved-modules/expected-result/run.txt index 75cd4fa4..8dc82ca3 100644 --- a/jigsaw-examples/example_resolved-modules/expected-result/run.txt +++ b/jigsaw-examples/example_resolved-modules/expected-result/run.txt @@ -1,18 +1,19 @@ Now we have these boot layer modules: -[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda] +[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda] Now we have these boot layer modules: -[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda, modb] +[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda, modb] Now we have these boot layer modules: -[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modc] +[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modc] Now we have these boot layer modules: -[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda, modb, modc] +[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda, modb, modc] Now we have these boot layer modules: -[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda, modb] +[java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, moda, modb] Now we have these boot layer modules: [java.base, moda, modb] Now we have these boot layer modules: [java.base, java.logging, moda, modb] -java.base file:///jmods/java.base.jmod +Linking based on the current run-time image +java.base jrt:/java.base (run-time image) moda file:///mlib/moda.jar modb file:///mlib/modb.jar diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/expected-result/run.txt b/jigsaw-examples/example_splitpackage_automatic-modules/expected-result/run.txt index 3a249429..788fba6a 100644 --- a/jigsaw-examples/example_splitpackage_automatic-modules/expected-result/run.txt +++ b/jigsaw-examples/example_splitpackage_automatic-modules/expected-result/run.txt @@ -1,6 +1,6 @@ Hello World from pkgmain.Main Layer's list of modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modmain Layer's configuration with its list of resolved modules: -java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.crypto.ec, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jfr, jdk.jlink, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modmain +java.base, java.compiler, java.datatransfer, java.desktop, java.logging, java.management, java.management.rmi, java.naming, java.prefs, java.rmi, java.security.jgss, java.security.sasl, java.smartcardio, java.xml, java.xml.crypto, jdk.attach, jdk.charsets, jdk.compiler, jdk.crypto.cryptoki, jdk.editpad, jdk.internal.ed, jdk.internal.jvmstat, jdk.internal.le, jdk.internal.md, jdk.internal.opt, jdk.jartool, jdk.javadoc, jdk.jdeps, jdk.jdi, jdk.jdwp.agent, jdk.jfr, jdk.jlink, jdk.jpackage, jdk.jshell, jdk.jstatd, jdk.localedata, jdk.management, jdk.management.jfr, jdk.naming.dns, jdk.naming.rmi, jdk.security.auth, jdk.security.jgss, jdk.unsupported.desktop, jdk.zipfs, modauto1, modmain diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc index 147561a0..dfd6d2e8 100644 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc @@ -49,7 +49,30 @@ An explicit `--add-opens` is hence needed. *Note that the kill switch **only works for classes which had been available before Java9**, i.e. were part of Java8. See also explanation https://docs.oracle.com/javase/9/tools/java.htm#JSWOR624[here].* -See all 20 different variants of how to use the `--illegal-access=...` command line option or the `--add-opens` option in the run script `run.sh`. +[[note:jdk_17_compatibility_changes]] +[NOTE] +.JDK 17+ Compatibility Changes +==== +The `--illegal-access` flag was deprecated in Java 16 and *removed in Java 17* (https://openjdk.org/jeps/403[JEP 403]). +Since Java 17, the behavior is always equivalent to `--illegal-access=deny` - deep reflective access to JDK internals is blocked by default. + +This example originally contained 20 variants demonstrating different combinations of `--illegal-access=permit/warn/deny` and `--add-opens`. +For JDK 17+ compatibility, the following variants were removed: + +* *Variants 2-4*: Used `--illegal-access=permit/warn/deny` for `java.base/jdk.internal.math` +* *Variants 6-9*: Used `--illegal-access` for `java.base/sun.net` (already commented out) +* *Variants 11-14*: Relied on `--illegal-access=permit` being the default for `java.desktop/sun.awt` +* *Variants 17-19*: Used `--illegal-access` for module `modb` + +The remaining variants (1, 5, 10, 15, 16, 20) demonstrate the only two behaviors now available in JDK 17+: + +. *Without options*: Reflective access to non-exported packages is blocked (throws `InaccessibleObjectException`) +. *With explicit `--add-opens`*: Reflective access is permitted + +For applications migrating to JDK 17+, replace any `--illegal-access` usage with explicit `--add-opens` flags. +==== + +See the run script `run.sh` for the remaining variants demonstrating `--add-opens` usage. === Output @@ -103,7 +126,7 @@ Hybrid compilation approach in `m4/compile.sh`: + The compilation order is critical: modules must be compiled and packaged before cpmain. + -. Runtime uses 20 test variants with various `--illegal-access` and `--add-opens` flags to demonstrate JDK encapsulation behavior +. Runtime uses test variants with `--add-opens` flags to demonstrate JDK encapsulation behavior (see <> note above) This hybrid approach is necessary because: @@ -111,4 +134,4 @@ This hybrid approach is necessary because: * Classpath code (unnamed module) must be compiled separately from explicit modules * Compilation order matters: cpmain depends on modb during compilation * The classpath/module-path split must be maintained at both compile-time and runtime -* The example demonstrates illegal reflective access behavior with various JVM flags +* The example demonstrates illegal reflective access behavior and `--add-opens` usage diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/expected-result/run.txt b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/expected-result/run.txt index 24366b08..91dafbc5 100644 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/expected-result/run.txt +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/expected-result/run.txt @@ -1,52 +1,7 @@ Caught exception: class java.lang.reflect.InaccessibleObjectException -Caught exception: class java.lang.reflect.InaccessibleObjectException -Caught exception: class java.lang.reflect.InaccessibleObjectException -Caught exception: class java.lang.reflect.InaccessibleObjectException jdk.internal.math.DoubleConsts -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -sun.net.PortConfig -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -sun.net.PortConfig -WARNING - content dropped due to output normalization sun.net.PortConfig -Caught exception: class java.lang.reflect.InaccessibleObjectException -sun.net.PortConfig -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -sun.awt.OSInfo -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -sun.awt.OSInfo -WARNING - content dropped due to output normalization sun.awt.OSInfo -Caught exception: class java.lang.reflect.InaccessibleObjectException -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -WARNING - content dropped due to output normalization -sun.awt.OSInfo -pkgb.BFromModule, id=ID_MainCallingModB_14 -Caught exception: class java.lang.reflect.InaccessibleObjectException -pkgb.BFromModule, id=ID_MainCallingModB_14 -Caught exception: class java.lang.reflect.InaccessibleObjectException -pkgb.BFromModule, id=ID_MainCallingModB_14 -Caught exception: class java.lang.reflect.InaccessibleObjectException pkgb.BFromModule, id=ID_MainCallingModB_14 Caught exception: class java.lang.reflect.InaccessibleObjectException pkgb.BFromModule, id=ID_MainCallingModB_14 diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh index 2cd17003..506007bb 100755 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh @@ -17,8 +17,9 @@ touch "${result_dir}/run.txt" # # Run main class, which does reflective access to a class from module java.base, package jdk.internal (a package which is new in Java9) -# Only variant #5 will work, while variants #1,#2,#3,#4 will show this exception: +# Only variant #5 will work (with explicit --add-opens), while variant #1 will throw: # java.lang.reflect.InaccessibleObjectException: Unable to make private jdk.internal.math.DoubleConsts() accessible: module java.base does not "opens jdk.internal.math" to unnamed module +# Note: Variants 2-4 with --illegal-access flag were removed - the flag was removed in Java 17 (JEP 403). echo "Checking variants of reflective access to java.base/jdk.internal.math.DoubleConsts. Its package is new in Java9!" @@ -29,27 +30,8 @@ if "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar pkgcpmain.M echo "ERROR: Variant 1 - Expected exception but command succeeded" exit 1 fi -echo -echo "2 - reflective call with --illegal-access=permit" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 2 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "3 - reflective call with --illegal-access=warn" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 3 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "4 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 4 - Expected exception but command succeeded" - exit 1 -fi +# Variants 2, 3, 4 removed: --illegal-access flag was removed in Java 17 +# See https://openjdk.org/jeps/403 - The behavior is now always "deny" echo echo "5 - reflective call with explicit --add-opens" echo "Should work without problems" @@ -64,41 +46,11 @@ echo # # Run main class, which does reflective access to a class from module java.base, package sun.net (a package which has existed before, in Java 8) -# Variants #5,#6, #7 and #8 will work, while -# variant #9 will show java.lang.reflect.InaccessibleObjectException: Unable to make private sun.net.PortConfig() accessible: module java.base does not "opens sun.net" to unnamed module -# variant #10 will show java.lang.ClassNotFoundException: sun.net.PortConfig +# Since Java 17, only variant #10 works (with explicit --add-opens). +# Note: Variants 6-9 with --illegal-access flag were removed - the flag was removed in Java 17 (JEP 403). echo "Checking variants of reflective access to java.base/sun.net.PortConfig. Its package is not new in Java 9, but had existed before in Java8!" -echo -echo "6 - reflective call without any options" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 6 - Expected success but got exception" - exit 1 -fi -echo -echo "7 - reflective call with --illegal-access=permit" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 7 - Expected success but got exception" - exit 1 -fi -echo -echo "8 - reflective call with --illegal-access=warn" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 8 - Expected success but got exception" - exit 1 -fi -echo -echo "9 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 9 - Expected exception but command succeeded" - exit 1 -fi - echo echo "10 - reflective call with explicit --add-opens" echo "Should work without problems" @@ -112,45 +64,22 @@ echo # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # -# Run main class, which does reflective access to a class from module java.desktop (a package which has existed before, in Java8) -# Variants #11,#12,#13 and #15 will work, while variant #14 will show this exception: -# java.lang.reflect.InaccessibleObjectException: Unable to make public com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel() accessible: module java.desktop does not "exports com.sun.java.swing.plaf.nimbus" to unnamed modul +# Run main class, which does reflective access to a class from module java.desktop, package sun.awt +# (a package which has existed before, in Java8). Since Java 17, only variant #15 works (with explicit --add-opens). +# Prior to Java 17, variants 11-13 worked when --illegal-access=permit was the default. # -echo "Checking variants of reflective access to java.desktop/com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel. Its package is not new in Java9, but had existed before in Java8!" +echo "Checking variants of reflective access to java.desktop/sun.awt.OSInfo. Its package is not new in Java9, but had existed before in Java8!" -echo -echo "11 - reflective call without any options" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 11 - Expected success but got exception" - exit 1 -fi -echo -echo "12 - reflective call with --illegal-access=permit" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 12 - Expected success but got exception" - exit 1 -fi -echo -echo "13 - reflective call with --illegal-access=warn" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 13 - Expected success but got exception" - exit 1 -fi -echo -echo "14 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 14 - Expected exception but command succeeded" - exit 1 -fi +# Variants 11-14 removed: --illegal-access flag was removed in Java 17 +# Previously, variants 11-13 relied on --illegal-access=permit being the default +# (allowing reflective access to packages that existed before Java 9). +# Since Java 17, the behavior is always "deny" - explicit --add-opens is required. +# See https://openjdk.org/jeps/403 echo echo "15 - reflective call with explicit --add-opens" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --add-opens=java.desktop/com.sun.java.swing.plaf.nimbus=ALL-UNNAMED --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --add-opens=java.desktop/sun.awt=ALL-UNNAMED --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 15 - Expected success but got exception" exit 1 fi @@ -161,8 +90,9 @@ echo # # Run main class, which does reflective access to a class from module modb (whose packages had not existed before Java9) -# Only variant #20 will work, while variants #16,#17,#18, and #19 will show this exception: -# java.lang.reflect.InaccessibleObjectException: Unable to make public pkgbinternal.BFromModuleButInternal() accessible: module modb does not "exports pkgbinternal" to unnamed module +# Only variant #20 will work (with explicit --add-opens), while variant #16 will throw InaccessibleObjectException. +# Note: Variants 17-19 with --illegal-access flag were removed - the flag was removed in Java 17 (JEP 403). +# The --illegal-access flag never applied to application modules like modb anyway; it only affected JDK internal packages. # echo "Checking variants of reflective access to the following classes in own module modb:" @@ -177,27 +107,9 @@ if "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar --add-modul echo "ERROR: Variant 16 - Expected exception but command succeeded" exit 1 fi -echo -echo "17 - reflective call with --illegal-access=permit" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 17 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "18 - reflective call with --illegal-access=warn" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 18 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "19 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then - echo "ERROR: Variant 19 - Expected exception but command succeeded" - exit 1 -fi +# Variants 17, 18, 19 removed: --illegal-access flag was removed in Java 17 +# The --illegal-access flag never applied to application modules like modb anyway; +# it only affected access to JDK internal packages. See https://openjdk.org/jeps/403 echo echo "20 - reflective call with explicit --add-opens" echo "Should work without problems" diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/run.sh b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/run.sh index e5f1073b..f9bd1d57 100755 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/run.sh +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/run.sh @@ -16,8 +16,9 @@ touch "${result_dir}/run.txt" # # Run main class, which does reflective access to a class from module java.base, package jdk.internal (a package which is new in Java9) -# Only variant #5 will work, while variants #1,#2,#3,#4 will show this exception: +# Only variant #5 will work (with explicit --add-opens), while variant #1 will throw: # java.lang.reflect.InaccessibleObjectException: Unable to make private jdk.internal.math.DoubleConsts() accessible: module java.base does not "opens jdk.internal.math" to unnamed module +# Note: Variants 2-4 with --illegal-access flag were removed - the flag was removed in Java 17 (JEP 403). echo "Checking variants of reflective access to java.base/jdk.internal.math.DoubleConsts. Its package is new in Java9!" @@ -28,27 +29,8 @@ if "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/ echo "ERROR: Variant 1 - Expected exception but command succeeded" exit 1 fi -echo -echo "2 - reflective call with --illegal-access=permit" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 2 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "3 - reflective call with --illegal-access=warn" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 3 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "4 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 4 - Expected exception but command succeeded" - exit 1 -fi +# Variants 2, 3, 4 removed: --illegal-access flag was removed in Java 17 +# See https://openjdk.org/jeps/403 - The behavior is now always "deny" echo echo "5 - reflective call with explicit --add-opens" echo "Should work without problems" @@ -63,41 +45,11 @@ echo # # Run main class, which does reflective access to a class from module java.base, package sun.net (a package which has existed before, in Java 8) -# Variants #5,#6, #7 and #8 will work, while -# variant #9 will show java.lang.reflect.InaccessibleObjectException: Unable to make private sun.net.PortConfig() accessible: module java.base does not "opens sun.net" to unnamed module -# variant #10 will show java.lang.ClassNotFoundException: sun.net.PortConfig +# Since Java 17, only variant #10 works (with explicit --add-opens). +# Note: Variants 6-9 with --illegal-access flag were removed - the flag was removed in Java 17 (JEP 403). echo "Checking variants of reflective access to java.base/sun.net.PortConfig. Its package is not new in Java 9, but had existed before in Java8!" -echo -echo "6 - reflective call without any options" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 6 - Expected success but got exception" - exit 1 -fi -echo -echo "7 - reflective call with --illegal-access=permit" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 7 - Expected success but got exception" - exit 1 -fi -echo -echo "8 - reflective call with --illegal-access=warn" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 8 - Expected success but got exception" - exit 1 -fi -echo -echo "9 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 9 - Expected exception but command succeeded" - exit 1 -fi - echo echo "10 - reflective call with explicit --add-opens" echo "Should work without problems" @@ -111,45 +63,22 @@ echo # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # -# Run main class, which does reflective access to a class from module java.desktop (a package which has existed before, in Java8) -# Variants #11,#12,#13 and #15 will work, while variant #14 will show this exception: -# java.lang.reflect.InaccessibleObjectException: Unable to make public com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel() accessible: module java.desktop does not "exports com.sun.java.swing.plaf.nimbus" to unnamed modul +# Run main class, which does reflective access to a class from module java.desktop, package sun.awt +# (a package which has existed before, in Java8). Since Java 17, only variant #15 works (with explicit --add-opens). +# Prior to Java 17, variants 11-13 worked when --illegal-access=permit was the default. # -echo "Checking variants of reflective access to java.desktop/com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel. Its package is not new in Java9, but had existed before in Java8!" +echo "Checking variants of reflective access to java.desktop/sun.awt.OSInfo. Its package is not new in Java9, but had existed before in Java8!" -echo -echo "11 - reflective call without any options" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 11 - Expected success but got exception" - exit 1 -fi -echo -echo "12 - reflective call with --illegal-access=permit" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 12 - Expected success but got exception" - exit 1 -fi -echo -echo "13 - reflective call with --illegal-access=warn" -echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 13 - Expected success but got exception" - exit 1 -fi -echo -echo "14 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 14 - Expected exception but command succeeded" - exit 1 -fi +# Variants 11-14 removed: --illegal-access flag was removed in Java 17 +# Previously, variants 11-13 relied on --illegal-access=permit being the default +# (allowing reflective access to packages that existed before Java 9). +# Since Java 17, the behavior is always "deny" - explicit --add-opens is required. +# See https://openjdk.org/jeps/403 echo echo "15 - reflective call with explicit --add-opens" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --add-opens=java.desktop/com.sun.java.swing.plaf.nimbus=ALL-UNNAMED --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then +if ! "${JAVA_HOME}/bin/java" --add-opens=java.desktop/sun.awt=ALL-UNNAMED --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then echo "ERROR: Variant 15 - Expected success but got exception" exit 1 fi @@ -160,8 +89,9 @@ echo # # Run main class, which does reflective access to a class from module modb (whose packages had not existed before Java9) -# Only variant #20 will work, while variants #16,#17,#18, and #19 will show this exception: -# java.lang.reflect.InaccessibleObjectException: Unable to make public pkgbinternal.BFromModuleButInternal() accessible: module modb does not "exports pkgbinternal" to unnamed module +# Only variant #20 will work (with explicit --add-opens), while variant #16 will throw InaccessibleObjectException. +# Note: Variants 17-19 with --illegal-access flag were removed - the flag was removed in Java 17 (JEP 403). +# The --illegal-access flag never applied to application modules like modb anyway; it only affected JDK internal packages. # echo "Checking variants of reflective access to the following classes in own module modb:" @@ -176,27 +106,9 @@ if "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/ echo "ERROR: Variant 16 - Expected exception but command succeeded" exit 1 fi -echo -echo "17 - reflective call with --illegal-access=permit" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 17 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "18 - reflective call with --illegal-access=warn" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 18 - Expected exception but command succeeded" - exit 1 -fi -echo -echo "19 - reflective call with --illegal-access=deny" -echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}"/run.txt | myecho; then - echo "ERROR: Variant 19 - Expected exception but command succeeded" - exit 1 -fi +# Variants 17, 18, 19 removed: --illegal-access flag was removed in Java 17 +# The --illegal-access flag never applied to application modules like modb anyway; +# it only affected access to JDK internal packages. See https://openjdk.org/jeps/403 echo echo "20 - reflective call with explicit --add-opens" echo "Should work without problems" diff --git a/jigsaw-examples/example_version/expected-result/run.txt b/jigsaw-examples/example_version/expected-result/run.txt index c757419f..69a31145 100644 --- a/jigsaw-examples/example_version/expected-result/run.txt +++ b/jigsaw-examples/example_version/expected-result/run.txt @@ -1,7 +1,7 @@ -Runtime.version() says, we are using Java version 11.0.28, build version 6 +Runtime.version() says, we are using Java version 25.0.1, build version 8 System properties say, we are using Java version as follows: - java.version = 11.0.28 - java.runtime.version = 11.0.28+6 - java.vm.version = 11.0.28+6 - java.specification.version = 11 - java.vm.specification.version = 11 + java.version = 25.0.1 + java.runtime.version = 25.0.1+8-LTS + java.vm.version = 25.0.1+8-LTS + java.specification.version = 25 + java.vm.specification.version = 25 From 44325b3a40e5dcc796c26c27c5e2b9773478e23a Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Wed, 31 Dec 2025 15:05:00 +0100 Subject: [PATCH 5/5] Drop M3_HOME as we will hardly ever migrate to M3 --- .envrc-template | 5 ----- CLAUDE.md | 1 - jigsaw-examples/env.sh | 4 ---- 3 files changed, 10 deletions(-) diff --git a/.envrc-template b/.envrc-template index 9c3602d1..2d581c88 100644 --- a/.envrc-template +++ b/.envrc-template @@ -38,10 +38,5 @@ export DEPVIS_HOME=/path/to/depvis # Note: M4_HOME is added to PATH in m4/compile.sh and m4/run.sh scripts, not globally export M4_HOME=/path/to/maven4 -# Path to Maven 3 (optional, for future m3/ migration comparisons) -# SDKMAN Users: Use 'sdk install maven 3.9.11' then 'sdk home maven 3.9.11' -# Optional -export M3_HOME=/path/to/maven3 - # Add Java to PATH to ensure it is the first Java version found by any shell execution export PATH="$JAVA_HOME/bin:$PATH" diff --git a/CLAUDE.md b/CLAUDE.md index cccedb3d..1120dbe9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -524,7 +524,6 @@ Before running any examples, `jigsaw-examples/env.sh` must be configured with: - `JAVA8_HOME`: Only needed for `example_compile-target-jdk8` - `JAVA17_HOME`: Only needed for `example_gradle-project` (Gradle 9.x requires JDK 17+) - `M4_HOME`: Path to Maven 4 (required for `m4/` migration subdirectories) -- `M3_HOME`: Path to Maven 3 (optional, for future `m3/` migration comparisons) - `GRAPHVIZ_HOME`: Path to GraphViz 2.38+ for module visualization - `DEPVIS_HOME`: Path to depvis tool (https://github.com/accso/java9-jigsaw-depvis) diff --git a/jigsaw-examples/env.sh b/jigsaw-examples/env.sh index 20f38ca3..615b4b3a 100644 --- a/jigsaw-examples/env.sh +++ b/jigsaw-examples/env.sh @@ -25,10 +25,6 @@ set -eu -o pipefail # Note: M4_HOME/bin is added to PATH in m4/ scripts, not here [ -z "${M4_HOME:-}" ] && export M4_HOME=TODO/path/to/maven4/goes/here -# Path to Maven 3 (optional, for future m3/ migration comparisons) -# SDKMAN Users: Use 'sdk install maven 3.9.11' or similar -[ -z "${M3_HOME:-}" ] && export M3_HOME=TODO/path/to/maven3/goes/here - # Path to GraphViz >=2.38 [ -z "${GRAPHVIZ_HOME:-}" ] && export GRAPHVIZ_HOME=TODO/path/to/graphviz2.38/goes/here # Path to DepVis , see https://github.com/accso/java9-jigsaw-depvis