Skip to content

Commit 8d3588f

Browse files
committed
build: run CI on JDK 17, fork tests on JDK 8, enforce --release 8
1 parent a4856e0 commit 8d3588f

6 files changed

Lines changed: 90 additions & 36 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ jobs:
4141
languages: ${{ matrix.language }}
4242
build-mode: manual
4343

44-
- name: Set up JDK 8
44+
# Gradle 9.1 requires JVM 17+ to run; bytecode still targets Java 8 via
45+
# sourceCompatibility. CodeQL only needs to compile, so JDK 17 is enough.
46+
- name: Set up JDK 17
4547
uses: actions/setup-java@v5
4648
with:
47-
java-version: '8'
49+
java-version: '17'
4850
distribution: 'temurin'
4951

5052
- name: Build

.github/workflows/dependency-check.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ jobs:
2626
restore-keys: |
2727
${{ runner.os }}-odc-data-
2828
29-
- name: Set up JDK 8
30-
uses: actions/setup-java@v3
29+
# Gradle 9.1 requires JVM 17+ to run; bytecode still targets Java 8 via
30+
# sourceCompatibility. This job only compiles (build -x test), so JDK 17 is enough.
31+
- name: Set up JDK 17
32+
uses: actions/setup-java@v4
3133
with:
32-
java-version: '8'
34+
java-version: '17'
3335
distribution: 'temurin'
3436

3537
- name: Gradlew build

.github/workflows/integration-test-multinode.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ jobs:
2525
- name: Checkout java-tron
2626
uses: actions/checkout@v5
2727

28-
- name: Set up JDK 8
28+
# Host builds FullNode.jar with JDK 17 (Gradle 9.1 needs JVM 17+); bytecode targets
29+
# Java 8. The FullNode itself still RUNS on JDK 8 inside the test container (below).
30+
- name: Set up JDK 17
2931
uses: actions/setup-java@v5
3032
with:
31-
java-version: '8'
33+
java-version: '17'
3234
distribution: 'temurin'
3335

3436
- name: Cache Gradle packages

.github/workflows/integration-test-single-node.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ jobs:
2525
- name: Checkout java-tron
2626
uses: actions/checkout@v5
2727

28-
- name: Set up JDK 8
28+
# Host builds FullNode.jar with JDK 17 (Gradle 9.1 needs JVM 17+); bytecode targets
29+
# Java 8. The FullNode itself still RUNS on JDK 8 inside the test container (below).
30+
- name: Set up JDK 17
2931
uses: actions/setup-java@v5
3032
with:
31-
java-version: '8'
33+
java-version: '17'
3234
distribution: 'temurin'
3335

3436
- name: Cache Gradle packages

.github/workflows/pr-build.yml

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,22 @@ jobs:
117117
LC_ALL: en_US.UTF-8
118118

119119
steps:
120-
- name: Install dependencies (Rocky 8 + JDK8)
120+
- name: Install dependencies (Rocky 8 + JDK 8 + JDK 17)
121121
run: |
122122
set -euxo pipefail
123-
dnf -y install java-1.8.0-openjdk-devel git wget unzip which jq bc curl glibc-langpack-en
123+
# JDK 8 runs the FullNode and the tests; JDK 17 runs Gradle (9.1 requires JVM 17+).
124+
dnf -y install java-1.8.0-openjdk-devel java-17-openjdk-devel git wget unzip which jq bc curl glibc-langpack-en
124125
dnf -y groupinstall "Development Tools"
126+
echo "JAVA8_HOME=$(readlink -f /usr/lib/jvm/java-1.8.0-openjdk)" >> "$GITHUB_ENV"
127+
echo "JAVA17_HOME=$(readlink -f /usr/lib/jvm/java-17-openjdk)" >> "$GITHUB_ENV"
125128
126129
- name: Checkout code
127130
uses: actions/checkout@v5
128131

129-
- name: Check Java version
130-
run: java -version
132+
- name: Check Java versions
133+
run: |
134+
"$JAVA8_HOME/bin/java" -version
135+
"$JAVA17_HOME/bin/java" -version
131136
132137
- name: Cache Gradle
133138
uses: actions/cache@v5
@@ -140,22 +145,26 @@ jobs:
140145
rockylinux-x86_64-gradle-
141146
142147
- name: Stop Gradle daemon
143-
run: ./gradlew --stop || true
148+
run: JAVA_HOME="$JAVA17_HOME" ./gradlew --stop || true
144149

145-
- name: Build
146-
run: ./gradlew clean build --no-daemon
150+
- name: Build (Gradle on JDK 17, tests forked on JDK 8)
151+
run: |
152+
JAVA_HOME="$JAVA17_HOME" ./gradlew clean build --no-daemon \
153+
-PtestJavaVersion=8 "-Porg.gradle.java.installations.paths=$JAVA8_HOME"
147154
148-
- name: Toolkit jar smoke test
155+
- name: Toolkit jar smoke test (JDK 8)
149156
run: |
150157
set -e
151158
JAR=plugins/build/libs/Toolkit.jar
152-
java -jar "$JAR" help
153-
java -jar "$JAR" db --help
154-
java -jar "$JAR" db archive -h
155-
java -jar "$JAR" keystore --help
159+
"$JAVA8_HOME/bin/java" -jar "$JAR" help
160+
"$JAVA8_HOME/bin/java" -jar "$JAR" db --help
161+
"$JAVA8_HOME/bin/java" -jar "$JAR" db archive -h
162+
"$JAVA8_HOME/bin/java" -jar "$JAR" keystore --help
156163
157-
- name: Test with RocksDB engine
158-
run: ./gradlew :framework:testWithRocksDb --no-daemon
164+
- name: Test with RocksDB engine (Gradle on JDK 17, tests on JDK 8)
165+
run: |
166+
JAVA_HOME="$JAVA17_HOME" ./gradlew :framework:testWithRocksDb --no-daemon \
167+
-PtestJavaVersion=8 "-Porg.gradle.java.installations.paths=$JAVA8_HOME"
159168
160169
docker-build-debian11:
161170
name: Build debian11 (JDK 8 / x86_64)
@@ -174,17 +183,26 @@ jobs:
174183
GRADLE_USER_HOME: /github/home/.gradle
175184

176185
steps:
177-
- name: Install dependencies (Debian + build tools)
186+
- name: Install dependencies (Debian + build tools + JDK 17 for Gradle)
178187
run: |
179188
set -euxo pipefail
180189
apt-get update
181190
apt-get install -y git wget unzip build-essential curl jq
191+
# JDK 8 (container default, /opt/java/openjdk) runs the FullNode and tests;
192+
# JDK 17 runs Gradle (9.1 requires JVM 17+).
193+
mkdir -p /opt/jdk17
194+
curl -fsSL "https://api.adoptium.net/v3/binary/latest/17/ga/linux/x64/jdk/hotspot/normal/eclipse" \
195+
| tar -xz --strip-components=1 -C /opt/jdk17
196+
echo "JAVA8_HOME=${JAVA_HOME:-/opt/java/openjdk}" >> "$GITHUB_ENV"
197+
echo "JAVA17_HOME=/opt/jdk17" >> "$GITHUB_ENV"
182198
183199
- name: Checkout code
184200
uses: actions/checkout@v5
185201

186-
- name: Check Java version
187-
run: java -version
202+
- name: Check Java versions
203+
run: |
204+
"$JAVA8_HOME/bin/java" -version
205+
"$JAVA17_HOME/bin/java" -version
188206
189207
- name: Cache Gradle
190208
uses: actions/cache@v5
@@ -196,23 +214,27 @@ jobs:
196214
restore-keys: |
197215
debian11-x86_64-gradle-
198216
199-
- name: Build
200-
run: ./gradlew clean build --no-daemon --no-build-cache
217+
- name: Build (Gradle on JDK 17, tests forked on JDK 8)
218+
run: |
219+
JAVA_HOME="$JAVA17_HOME" ./gradlew clean build --no-daemon --no-build-cache \
220+
-PtestJavaVersion=8 "-Porg.gradle.java.installations.paths=$JAVA8_HOME"
201221
202-
- name: Toolkit jar smoke test
222+
- name: Toolkit jar smoke test (JDK 8)
203223
run: |
204224
set -e
205225
JAR=plugins/build/libs/Toolkit.jar
206-
java -jar "$JAR" help
207-
java -jar "$JAR" db --help
208-
java -jar "$JAR" db archive -h
209-
java -jar "$JAR" keystore --help
226+
"$JAVA8_HOME/bin/java" -jar "$JAR" help
227+
"$JAVA8_HOME/bin/java" -jar "$JAR" db --help
228+
"$JAVA8_HOME/bin/java" -jar "$JAR" db archive -h
229+
"$JAVA8_HOME/bin/java" -jar "$JAR" keystore --help
210230
211-
- name: Test with RocksDB engine
212-
run: ./gradlew :framework:testWithRocksDb --no-daemon --no-build-cache
231+
- name: Test with RocksDB engine (Gradle on JDK 17, tests on JDK 8)
232+
run: |
233+
JAVA_HOME="$JAVA17_HOME" ./gradlew :framework:testWithRocksDb --no-daemon --no-build-cache \
234+
-PtestJavaVersion=8 "-Porg.gradle.java.installations.paths=$JAVA8_HOME"
213235
214236
- name: Generate module coverage reports
215-
run: ./gradlew jacocoTestReport --no-daemon
237+
run: JAVA_HOME="$JAVA17_HOME" ./gradlew jacocoTestReport --no-daemon
216238

217239
- name: Upload PR coverage reports
218240
uses: actions/upload-artifact@v6

build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,30 @@ subprojects {
6565
targetCompatibility = JavaVersion.VERSION_1_8
6666
}
6767

68+
// -target 8 only sets the bytecode version; method calls still resolve against the build JDK's
69+
// classes, so a JDK 9+ API compiles on JDK 17 but fails at RUNTIME on JDK 8 (NoSuchMethodError).
70+
// --release 8 compiles against the historical JDK 8 API so such usage is a compile error,
71+
// regardless of which JDK runs Gradle. errorprone is excluded: it uses jdk.compiler internals
72+
// and only runs on the build JVM, never on the JDK 8 runtime.
73+
if (project.name != 'errorprone') {
74+
tasks.withType(JavaCompile).configureEach {
75+
options.release = 8
76+
}
77+
}
78+
79+
// Gradle 9.1 must run on JVM 17+, but the x86 stack is validated on JDK 8. When CI passes
80+
// -PtestJavaVersion=8, test JVMs are forked on that JDK (classes are still compiled to bytecode 8
81+
// by the Gradle JVM); Gradle locates the JDK via -Porg.gradle.java.installations.paths. Without
82+
// the property, tests run on the Gradle JVM (arm64 JDK 17-21 and local dev) — unchanged.
83+
if (project.hasProperty('testJavaVersion')) {
84+
tasks.withType(Test).configureEach {
85+
javaLauncher.set(javaToolchains.launcherFor {
86+
languageVersion = JavaLanguageVersion.of(
87+
Integer.parseInt(project.property('testJavaVersion').toString()))
88+
})
89+
}
90+
}
91+
6892
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
6993
jacoco {
7094
toolVersion = "0.8.15" // see https://www.jacoco.org/jacoco/trunk/doc/changes.html

0 commit comments

Comments
 (0)