Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions .envrc-template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,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"
80 changes: 20 additions & 60 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,45 +56,33 @@ jobs:
distribution: 'zulu'
java-version: '8'

- name: Set up JDK 11
id: setup-jdk11
- name: Set up JDK
id: setup-jdk
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
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 }}
JAVA11_PATH: ${{ steps.setup-jdk11.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")"
JAVA11_PATH="$(cygpath -u "$JAVA11_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=$JAVA11_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
Expand All @@ -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
Expand Down Expand Up @@ -190,19 +172,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v5

- name: Set up JDK 11
id: setup-jdk11
- name: Set up JDK
id: setup-jdk
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '11.0.28'

- name: Set up JDK 17
id: setup-jdk17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
java-version: '25.0.1'

- name: Set up Maven 4
uses: stCarolas/setup-maven@v5
Expand All @@ -214,8 +189,7 @@ jobs:
- name: Create .envrc with Java and Maven paths
shell: bash
env:
JAVA11_PATH: ${{ steps.setup-jdk11.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
Expand All @@ -233,23 +207,16 @@ jobs:

# Convert Windows paths to Unix paths if on Windows
if [[ "$RUNNER_OS" == "Windows" ]]; then
JAVA11_PATH="$(cygpath -u "$JAVA11_PATH")"
JAVA17_PATH="$(cygpath -u "$JAVA17_PATH")"
JAVA_PATH="$(cygpath -u "$JAVA_PATH")"
MAVEN4_PATH="$(cygpath -u "$MAVEN4_PATH")"
fi

cat > .envrc << EOF
# 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=$JAVA11_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
Expand All @@ -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 ==="
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 15 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<recommended-jdk>>).
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.
====

Expand Down
18 changes: 4 additions & 14 deletions jigsaw-examples/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -31,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
Expand Down
2 changes: 1 addition & 1 deletion jigsaw-examples/example_addExports_manifest/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
9 changes: 1 addition & 8 deletions jigsaw-examples/example_addExports_manifest/m4/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -26,6 +19,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

7 changes: 2 additions & 5 deletions jigsaw-examples/example_addExports_manifest/m4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -32,12 +32,9 @@
<version>4.0.0-beta-3</version>
<configuration>
<compilerArgs>
<!-- Use JDK 11's system modules for compilation (to access JDK 11 internals) -->
<arg>--system</arg>
<arg>${env.JAVA11_HOME}</arg>
<!-- Required for modmain to access internal JDK and moda packages at compile time -->
<arg>--add-exports</arg>
<arg>java.base/jdk.internal.misc=modmain</arg>
<arg>java.base/jdk.internal.org.xml.sax=modmain</arg>
<arg>--add-exports</arg>
<arg>moda/pkgainternal=modmain</arg>
</compilerArgs>
Expand Down
14 changes: 4 additions & 10 deletions jigsaw-examples/example_addExports_manifest/m4/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,24 @@ 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
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 \
"${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
2 changes: 1 addition & 1 deletion jigsaw-examples/example_addExports_manifest/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading