Skip to content

Commit 408242a

Browse files
authored
Upgrade GraalVM and Truffle, set up multi-JDK testing, bump development Java to 21 (#876)
This updates the GraalVM and Truffle libraries to 2024.1.2. This also updates the build logic to compile Java sources using Java 21, due to some compile-only dependencies within GraalVM/Truffle using class file version 65. However, the produced artifact is still compatible with Java 17. This also changes the Gradle build logic to use toolchains, and to test the Java libraries with JDK 17 and 21. One consequence of this change is that Truffle is no longer shaded within the fat jars. feat: support for jvm21+ toolchain feat: support for gradle toolchains feat: pass -PnativeArch=native to build with -march=native test: multi-jdk testing support test: support for jvm-test-suite plugin test: add tasks to run jpkl eval on multiple jdks test: make jdk exec tests respect multi-jdk flags and ranges fix: remove mrjar classes at >jvm17 from fatjars fix: use jdk21 to run the tests (needed for Unsafe.ensureInitialized) fix: truffle svm dependency is required after graalvm 24.0.0 fix: warnings for gvm flag usage, renamed truffle svm macro fix: build with --add-modules=jdk.unsupported where needed fix: don't use gu tool for modern graalvm versions fix: catch Throwable instead of deprecated-for-removal ThreadDeath chore: buildinfo changes for JVM targets, toolchains chore: enforce testing at exactly jdk21 chore: enforce build tooling at jdk21+ chore: bump graalvm/truffle libs → 24.1.2 chore: toolchains for buildSrc Signed-off-by: Sam Gammon <[email protected]>
1 parent 8cfd235 commit 408242a

37 files changed

+747
-181
lines changed

.circleci/config.pkl

+3-8
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,13 @@ local buildNativeJobs: Mapping<String, BuildNativeJob> = new {
105105
}
106106

107107
local gradleCheckJobs: Mapping<String, GradleCheckJob> = new {
108-
["gradle-check-jdk17"] {
109-
javaVersion = "17.0"
110-
isRelease = false
111-
os = "linux"
112-
}
113-
["gradle-check-jdk21"] {
108+
["gradle-check"] {
114109
javaVersion = "21.0"
115110
isRelease = false
116111
os = "linux"
117112
}
118-
["gradle-check-jdk17-windows"] {
119-
javaVersion = "17.0"
113+
["gradle-check-windows"] {
114+
javaVersion = "21.0"
120115
isRelease = false
121116
os = "windows"
122117
}

.circleci/config.yml

+33-58
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- run:
1313
command: |-
1414
export PATH=~/staticdeps/bin:$PATH
15-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
15+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
1616
name: gradle buildNative
1717
- persist_to_workspace:
1818
root: '.'
@@ -88,7 +88,7 @@ jobs:
8888
- run:
8989
command: |-
9090
export PATH=~/staticdeps/bin:$PATH
91-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
91+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
9292
name: gradle buildNative
9393
- persist_to_workspace:
9494
root: '.'
@@ -108,7 +108,7 @@ jobs:
108108
- run:
109109
command: |-
110110
export PATH=~/staticdeps/bin:$PATH
111-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
111+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
112112
name: gradle buildNative
113113
- persist_to_workspace:
114114
root: '.'
@@ -168,7 +168,7 @@ jobs:
168168
- run:
169169
command: |-
170170
export PATH=~/staticdeps/bin:$PATH
171-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
171+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
172172
name: gradle buildNative
173173
- persist_to_workspace:
174174
root: '.'
@@ -245,7 +245,7 @@ jobs:
245245
- run:
246246
command: |-
247247
export PATH=~/staticdeps/bin:$PATH
248-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
248+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
249249
name: gradle buildNative
250250
- persist_to_workspace:
251251
root: '.'
@@ -277,7 +277,7 @@ jobs:
277277
- run:
278278
command: |-
279279
export PATH=~/staticdeps/bin:$PATH
280-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
280+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
281281
name: gradle buildNative
282282
shell: bash.exe
283283
- persist_to_workspace:
@@ -301,7 +301,7 @@ jobs:
301301
- run:
302302
command: |-
303303
export PATH=~/staticdeps/bin:$PATH
304-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
304+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
305305
name: gradle buildNative
306306
- persist_to_workspace:
307307
root: '.'
@@ -377,7 +377,7 @@ jobs:
377377
- run:
378378
command: |-
379379
export PATH=~/staticdeps/bin:$PATH
380-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
380+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
381381
name: gradle buildNative
382382
- persist_to_workspace:
383383
root: '.'
@@ -397,7 +397,7 @@ jobs:
397397
- run:
398398
command: |-
399399
export PATH=~/staticdeps/bin:$PATH
400-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
400+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
401401
name: gradle buildNative
402402
- persist_to_workspace:
403403
root: '.'
@@ -457,7 +457,7 @@ jobs:
457457
- run:
458458
command: |-
459459
export PATH=~/staticdeps/bin:$PATH
460-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
460+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
461461
name: gradle buildNative
462462
- persist_to_workspace:
463463
root: '.'
@@ -534,7 +534,7 @@ jobs:
534534
- run:
535535
command: |-
536536
export PATH=~/staticdeps/bin:$PATH
537-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
537+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
538538
name: gradle buildNative
539539
- persist_to_workspace:
540540
root: '.'
@@ -566,7 +566,7 @@ jobs:
566566
- run:
567567
command: |-
568568
export PATH=~/staticdeps/bin:$PATH
569-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
569+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
570570
name: gradle buildNative
571571
shell: bash.exe
572572
- persist_to_workspace:
@@ -581,38 +581,26 @@ jobs:
581581
resource_class: windows.large
582582
machine:
583583
image: windows-server-2022-gui:current
584-
gradle-check-jdk17:
584+
gradle-check:
585585
steps:
586586
- checkout
587587
- run:
588-
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results check
589-
name: gradle check
590-
- store_test_results:
591-
path: ~/test-results
592-
environment:
593-
LANG: en_US.UTF-8
594-
docker:
595-
- image: cimg/openjdk:17.0
596-
gradle-check-jdk21:
597-
steps:
598-
- checkout
599-
- run:
600-
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results check
588+
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true check
601589
name: gradle check
602590
- store_test_results:
603591
path: ~/test-results
604592
environment:
605593
LANG: en_US.UTF-8
606594
docker:
607595
- image: cimg/openjdk:21.0
608-
gradle-check-jdk17-windows:
596+
gradle-check-windows:
609597
steps:
610598
- checkout
611599
- run:
612600
command: |-
613601
# install jdk
614602
curl -Lf \
615-
https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9.1/OpenJDK17U-jdk_x64_windows_hotspot_17.0.9_9.zip -o /tmp/jdk.zip
603+
https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jdk_x64_windows_hotspot_21.0.5_11.zip -o /tmp/jdk.zip
616604
617605
unzip /tmp/jdk.zip -d /tmp/jdk \
618606
&& cd /tmp/jdk/jdk-* \
@@ -621,7 +609,7 @@ jobs:
621609
name: Set up environment
622610
shell: bash.exe
623611
- run:
624-
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results check
612+
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true check
625613
name: gradle check
626614
- store_test_results:
627615
path: ~/test-results
@@ -635,7 +623,7 @@ jobs:
635623
steps:
636624
- checkout
637625
- run:
638-
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results bench:jmh
626+
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true bench:jmh
639627
name: bench:jmh
640628
- store_test_results:
641629
path: ~/test-results
@@ -648,7 +636,7 @@ jobs:
648636
- checkout
649637
- run:
650638
command: |-
651-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results :pkl-gradle:build \
639+
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true :pkl-gradle:build \
652640
:pkl-gradle:compatibilityTestReleases
653641
name: gradle compatibility
654642
- store_test_results:
@@ -663,7 +651,7 @@ jobs:
663651
- attach_workspace:
664652
at: '.'
665653
- run:
666-
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results publishToSonatype
654+
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true publishToSonatype
667655
- persist_to_workspace:
668656
root: '.'
669657
paths:
@@ -680,7 +668,7 @@ jobs:
680668
- attach_workspace:
681669
at: '.'
682670
- run:
683-
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true publishToSonatype closeAndReleaseSonatypeStagingRepository
671+
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true publishToSonatype closeAndReleaseSonatypeStagingRepository
684672
- persist_to_workspace:
685673
root: '.'
686674
paths:
@@ -742,13 +730,10 @@ workflows:
742730
type: approval
743731
- pr-approval/authenticate:
744732
context: pkl-pr-approval
745-
- gradle-check-jdk17:
733+
- gradle-check:
746734
requires:
747735
- hold
748-
- gradle-check-jdk21:
749-
requires:
750-
- hold
751-
- gradle-check-jdk17-windows:
736+
- gradle-check-windows:
752737
requires:
753738
- hold
754739
when:
@@ -757,9 +742,8 @@ workflows:
757742
pattern: ^pull/\d+(/head)?$
758743
main:
759744
jobs:
760-
- gradle-check-jdk17
761-
- gradle-check-jdk21
762-
- gradle-check-jdk17-windows
745+
- gradle-check
746+
- gradle-check-windows
763747
- bench
764748
- gradle-compatibility
765749
- pkl-cli-macOS-amd64-snapshot
@@ -770,9 +754,8 @@ workflows:
770754
- pkl-cli-windows-amd64-snapshot
771755
- deploy-snapshot:
772756
requires:
773-
- gradle-check-jdk17
774-
- gradle-check-jdk21
775-
- gradle-check-jdk17-windows
757+
- gradle-check
758+
- gradle-check-windows
776759
- bench
777760
- gradle-compatibility
778761
- pkl-cli-macOS-amd64-snapshot
@@ -793,19 +776,13 @@ workflows:
793776
- << pipeline.git.branch >>
794777
release:
795778
jobs:
796-
- gradle-check-jdk17:
797-
filters:
798-
branches:
799-
ignore: /.*/
800-
tags:
801-
only: /^v?\d+\.\d+\.\d+$/
802-
- gradle-check-jdk21:
779+
- gradle-check:
803780
filters:
804781
branches:
805782
ignore: /.*/
806783
tags:
807784
only: /^v?\d+\.\d+\.\d+$/
808-
- gradle-check-jdk17-windows:
785+
- gradle-check-windows:
809786
filters:
810787
branches:
811788
ignore: /.*/
@@ -861,9 +838,8 @@ workflows:
861838
only: /^v?\d+\.\d+\.\d+$/
862839
- github-release:
863840
requires:
864-
- gradle-check-jdk17
865-
- gradle-check-jdk21
866-
- gradle-check-jdk17-windows
841+
- gradle-check
842+
- gradle-check-windows
867843
- bench
868844
- gradle-compatibility
869845
- pkl-cli-macOS-amd64-release
@@ -899,9 +875,8 @@ workflows:
899875
only: /^v?\d+\.\d+\.\d+$/
900876
release-branch:
901877
jobs:
902-
- gradle-check-jdk17
903-
- gradle-check-jdk21
904-
- gradle-check-jdk17-windows
878+
- gradle-check
879+
- gradle-check-windows
905880
- bench
906881
- gradle-compatibility
907882
- pkl-cli-macOS-amd64-release

.circleci/jobs/GradleJob.pkl

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fixed gradleArgs = new Listing {
4747
"--info"
4848
"--stacktrace"
4949
"-DtestReportsDir=${HOME}/test-results"
50+
"-DpklMultiJdkTesting=true"
5051
when (isRelease) {
5152
"-DreleaseBuild=true"
5253
}

.java-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
17.0
1+
21

DEVELOPMENT.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
== Setup
99

10-
. (mandatory) Install a JDK (any version between 17 - 21).
10+
. (mandatory) Install a JDK (JDK 21+ required).
1111
. (recommended) Install {uri-intellij}[IntelliJ IDEA] +
1212
To import the project into IntelliJ, go to File->Open and select the project's root directory.
1313
If the project is opened but not imported, look for a popup in the lower right corner
@@ -17,7 +17,7 @@ _gng_ enables to run Gradle commands with `gw` (instead of `./gradlew`) from any
1717
. (recommended) Set up Git ignore-revs +
1818
`git config blame.ignoreRevsFile .git-blame-ignore-revs`
1919
. (recommended) Install {uri-jenv}[jenv] and plugins +
20-
_jenv_ use specific JDK versions in certain subdirectories. _Pkl_ comes with a `.java-version` file specifying JDK 17. +
20+
_jenv_ use specific JDK versions in certain subdirectories. _Pkl_ comes with a `.java-version` file specifying JDK 21. +
2121
Enable _jenv_ plugins for better handling by `gradle`:
2222
+
2323
[source,shell]

bench/gradle.lockfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ net.sf.jopt-simple:jopt-simple:5.0.4=jmh,jmhCompileClasspath,jmhImplementationDe
77
org.apache.commons:commons-math3:3.6.1=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath
88
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
99
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
10-
org.graalvm.compiler:compiler:23.0.6=graal
11-
org.graalvm.sdk:graal-sdk:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle
12-
org.graalvm.truffle:truffle-api:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle
10+
org.graalvm.compiler:compiler:24.1.2=graal
11+
org.graalvm.polyglot:polyglot:24.1.2=jmh,jmhRuntimeClasspath,truffle
12+
org.graalvm.sdk:collections:24.1.2=graal,jmh,jmhRuntimeClasspath,truffle
13+
org.graalvm.sdk:graal-sdk:24.1.2=jmh,jmhRuntimeClasspath
14+
org.graalvm.sdk:nativeimage:24.1.2=jmh,jmhRuntimeClasspath,truffle
15+
org.graalvm.sdk:word:24.1.2=graal,jmh,jmhRuntimeClasspath,truffle
16+
org.graalvm.truffle:truffle-api:24.1.2=jmh,jmhRuntimeClasspath,truffle
17+
org.graalvm.truffle:truffle-compiler:24.1.2=graal
1318
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
1419
org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
1520
org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath

buildSrc/build.gradle.kts

+18-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
*/
1616
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1717

18-
plugins { `kotlin-dsl` }
18+
plugins {
19+
`kotlin-dsl`
20+
`jvm-toolchains`
21+
}
22+
23+
// Keep this in sync with the constants in `BuildInfo.kt` (those are not addressable here).
24+
val toolchainVersion = 21
1925

2026
dependencies {
2127
implementation(libs.downloadTaskPlugin)
@@ -29,8 +35,16 @@ dependencies {
2935
}
3036

3137
java {
32-
sourceCompatibility = JavaVersion.VERSION_17
33-
targetCompatibility = JavaVersion.VERSION_17
38+
sourceCompatibility = JavaVersion.toVersion(toolchainVersion)
39+
targetCompatibility = JavaVersion.toVersion(toolchainVersion)
40+
41+
toolchain {
42+
languageVersion = JavaLanguageVersion.of(toolchainVersion)
43+
vendor = JvmVendorSpec.ADOPTIUM
44+
}
3445
}
3546

36-
kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_17 } }
47+
kotlin {
48+
jvmToolchain(toolchainVersion)
49+
compilerOptions { jvmTarget = JvmTarget.fromTarget(toolchainVersion.toString()) }
50+
}

0 commit comments

Comments
 (0)