This PR updates dependencies and build process for Pkl to bring GraalVM and Truffle support up to their latest versions. Today, Pkl builds against Java 17+, and requires Java 17+ to run.
After merging this PR, Pkl would build against Java 21, test against Java 21, and impose no change to lib consumers (i.e. still only requiring Java 17+ to run or transitively compile against Pkl).
Test downstream here (updated), via Github Actions. On that fork PR, the change set is expressed in full, with fixups.
Gradle Toolchains: Uses Gradle's toolchains feature to provision and use different versions of the JDK.
JDK 21 Toolchain: Builds (and tests) occur under JDK 21, with bytecode targeting JVM 17. Build bytecode adopts JVM 21 to accelerate build tooling with no change to lib consumers.
Truffle SVM Dependency: Certain superclasses used by Pkl (notably, AbstractTruffleException and TruffleFeature) have moved to the new org.graalvm.nativeimage:truffle-runtime-svm coordinate.
Multi-JDK testing: Adds stronger guarantees for backward compatibility with regard to Pkl and JVM execution (i.e. java -jar ... with a fat JAR). Tests against versions 18-23 with test suites and java -jar ... executions.
Known Issues
Failing Tests (pkl-gradle)
Exports on JVM17: Running against newer Truffle on JVM17 may need --add-exports=...
Pre-merge Checklist
Refresh Gradle lockfiles and review
Changelog
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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/876
**Author:** [@sgammon](https://github.com/sgammon)
**Created:** 1/6/2025
**Status:** ✅ Merged
**Merged:** 2/3/2025
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `feat/jvm21plus-upstream`
---
### 📝 Commits (2)
- [`8b29630`](https://github.com/apple/pkl/commit/8b296307e1ca21a6974a9af12cfd60fa8f9f3059) feat: graalvm jdk21 toolchain
- [`87a03af`](https://github.com/apple/pkl/commit/87a03af8ab5294afeb53529e529e07921f50eb1a) chore: update circleci jobs for multi-jdk testing
### 📊 Changes
**37 files changed** (+747 additions, -181 deletions)
<details>
<summary>View changed files</summary>
📝 `.circleci/config.pkl` (+3 -8)
📝 `.circleci/config.yml` (+33 -58)
📝 `.circleci/jobs/GradleJob.pkl` (+1 -0)
📝 `.java-version` (+1 -1)
📝 `DEVELOPMENT.adoc` (+2 -2)
📝 `bench/gradle.lockfile` (+8 -3)
📝 `buildSrc/build.gradle.kts` (+18 -4)
📝 `buildSrc/settings.gradle.kts` (+3 -1)
📝 `buildSrc/src/main/kotlin/BuildInfo.kt` (+266 -3)
📝 `buildSrc/src/main/kotlin/InstallGraalVm.kt` (+12 -6)
➕ `buildSrc/src/main/kotlin/JavaVersionRange.kt` (+64 -0)
📝 `buildSrc/src/main/kotlin/pklFatJar.gradle.kts` (+18 -4)
📝 `buildSrc/src/main/kotlin/pklGradlePluginTest.gradle.kts` (+1 -1)
📝 `buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts` (+64 -7)
📝 `buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts` (+8 -2)
📝 `buildSrc/src/main/kotlin/pklKotlinTest.gradle.kts` (+5 -2)
📝 `docs/gradle.lockfile` (+6 -2)
📝 `docs/src/test/kotlin/DocSnippetTests.kt` (+1 -0)
📝 `gradle.properties` (+2 -0)
📝 `gradle/libs.versions.toml` (+9 -7)
_...and 17 more files_
</details>
### 📄 Description
## Summary
This PR updates dependencies and build process for Pkl to bring GraalVM and Truffle support up to their latest versions. Today, Pkl builds against Java 17+, and requires Java 17+ to run.
After merging this PR, Pkl would build against Java 21, test against Java 21, and impose no change to lib consumers (i.e. still only requiring Java 17+ to run or transitively compile against Pkl).
Test downstream [here (updated)](https://github.com/elide-dev/pkl/pull/6), via Github Actions. On that fork PR, the change set is expressed in full, with fixups.
### PR Tree
- apple/pkl-project-commons#6
- #914 (split out into independent PR)
- #919 (split out into independent PR)
- #920 (split out into independent PR)
## Rationale
- **Gradle Toolchains:** Uses Gradle's toolchains feature to provision and use different versions of the JDK.
- **JDK 21 Toolchain**: Builds (and tests) occur under JDK 21, with bytecode targeting JVM 17. Build bytecode adopts JVM 21 to accelerate build tooling with no change to lib consumers.
- **Truffle SVM Dependency**: Certain superclasses used by Pkl (notably, `AbstractTruffleException` and `TruffleFeature`) have moved to the new [`org.graalvm.nativeimage:truffle-runtime-svm`](https://central.sonatype.com/artifact/org.graalvm.nativeimage/truffle-runtime-svm) coordinate.
- **Multi-JDK testing**: Adds stronger guarantees for backward compatibility with regard to Pkl and JVM execution (i.e. `java -jar ...` with a fat JAR). Tests against versions 18-23 with test suites and `java -jar ...` executions.
## Known Issues
- [x] **Failing Tests** (`pkl-gradle`)
- [x] **Exports on JVM17**: Running against newer Truffle on JVM17 may need `--add-exports=...`
### Pre-merge Checklist
- [x] Refresh Gradle lockfiles and review
## Changelog
- 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`
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/876
Author: @sgammon
Created: 1/6/2025
Status: ✅ Merged
Merged: 2/3/2025
Merged by: @bioball
Base:
main← Head:feat/jvm21plus-upstream📝 Commits (2)
8b29630feat: graalvm jdk21 toolchain87a03afchore: update circleci jobs for multi-jdk testing📊 Changes
37 files changed (+747 additions, -181 deletions)
View changed files
📝
.circleci/config.pkl(+3 -8)📝
.circleci/config.yml(+33 -58)📝
.circleci/jobs/GradleJob.pkl(+1 -0)📝
.java-version(+1 -1)📝
DEVELOPMENT.adoc(+2 -2)📝
bench/gradle.lockfile(+8 -3)📝
buildSrc/build.gradle.kts(+18 -4)📝
buildSrc/settings.gradle.kts(+3 -1)📝
buildSrc/src/main/kotlin/BuildInfo.kt(+266 -3)📝
buildSrc/src/main/kotlin/InstallGraalVm.kt(+12 -6)➕
buildSrc/src/main/kotlin/JavaVersionRange.kt(+64 -0)📝
buildSrc/src/main/kotlin/pklFatJar.gradle.kts(+18 -4)📝
buildSrc/src/main/kotlin/pklGradlePluginTest.gradle.kts(+1 -1)📝
buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts(+64 -7)📝
buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts(+8 -2)📝
buildSrc/src/main/kotlin/pklKotlinTest.gradle.kts(+5 -2)📝
docs/gradle.lockfile(+6 -2)📝
docs/src/test/kotlin/DocSnippetTests.kt(+1 -0)📝
gradle.properties(+2 -0)📝
gradle/libs.versions.toml(+9 -7)...and 17 more files
📄 Description
Summary
This PR updates dependencies and build process for Pkl to bring GraalVM and Truffle support up to their latest versions. Today, Pkl builds against Java 17+, and requires Java 17+ to run.
After merging this PR, Pkl would build against Java 21, test against Java 21, and impose no change to lib consumers (i.e. still only requiring Java 17+ to run or transitively compile against Pkl).
Test downstream here (updated), via Github Actions. On that fork PR, the change set is expressed in full, with fixups.
PR Tree
Rationale
Gradle Toolchains: Uses Gradle's toolchains feature to provision and use different versions of the JDK.
JDK 21 Toolchain: Builds (and tests) occur under JDK 21, with bytecode targeting JVM 17. Build bytecode adopts JVM 21 to accelerate build tooling with no change to lib consumers.
Truffle SVM Dependency: Certain superclasses used by Pkl (notably,
AbstractTruffleExceptionandTruffleFeature) have moved to the neworg.graalvm.nativeimage:truffle-runtime-svmcoordinate.Multi-JDK testing: Adds stronger guarantees for backward compatibility with regard to Pkl and JVM execution (i.e.
java -jar ...with a fat JAR). Tests against versions 18-23 with test suites andjava -jar ...executions.Known Issues
pkl-gradle)--add-exports=...Pre-merge Checklist
Changelog
-PnativeArch=nativeto build with-march=nativejvm-test-suitepluginjpkl evalon multiple jdksUnsafe.ensureInitialized)24.0.0--add-modules=jdk.unsupportedwhere neededgutool for modern graalvm versionsThrowableinstead of deprecated-for-removalThreadDeath24.1.2buildSrc🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.