-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK 21 toolchain #876
base: main
Are you sure you want to change the base?
JDK 21 toolchain #876
Conversation
8c2a05f
to
dc45756
Compare
pkl-core/src/test/files/LanguageSnippetTests/input/errors/analyzeInvalidHttpModule.inert
Outdated
Show resolved
Hide resolved
This is great, thanks, Sam! I will do a review of this by next week. FYI: Pkl today supports Java 21. The range enabled here is Java 22+ (updated your PR title). |
This comment was marked as outdated.
This comment was marked as outdated.
@sgammon feel free to extract the toolchain support into another PR. Indeed, my PR is quited dated. I will close it... |
@StefMa roger, no worries :) I am a well known offender in that regard |
dc45756
to
1982880
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
Also, general note: we'll need to set up our CI to use Java 21 to compile (for various compileJava
tasks), and ideally to test with all of JDK 17/21/22+. I actually think toolchains probably makes sense for this, so, I'd be okay with the toolchain changes coming back into this PR.
With toolchains, maybe the version of Java used for tasks.test
can come from a build flag.
pkl-core/src/main/resources/META-INF/native-image/org.pkl-lang/native-image.properties
Outdated
Show resolved
Hide resolved
1982880
to
a314e92
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
f9daed3
to
263588b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial support for multi-JDK testing. Runs testsuites as well as pkl-cli
execution tests across JDK 18-23 (with JDK22 and JDK23 as experimental targets, so failures do not block the build).
This change is isolated to one commit so that it can be dropped or included here easily.
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
8bfd605
to
d087ea6
Compare
Rebased against main to pick up #900 |
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
private fun labelForVendor(vendor: JvmVendorSpec): String = | ||
when (vendor) { | ||
JvmVendorSpec.AZUL -> "Zulu" | ||
JvmVendorSpec.GRAAL_VM -> "GraalVm" | ||
JvmVendorSpec.ORACLE -> "Oracle" | ||
JvmVendorSpec.ADOPTIUM -> "OpenJdk" | ||
else -> error("Unrecognized JDK vendor: $vendor") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multi-vendor JDK testing is off by default, but supported, in cases where checking compat across vendors is desirable. It adds test tasks to the check
matrix if activated.
By default, multi-JDK tests are run against Azul Zulu for speed. With multi-vendor testing on, they are additionally run with GraalVM CE and Oracle JDKs.
// must match the minimum JVM bytecode target for Pkl | ||
jvmTarget = JvmTarget.fromTarget(buildInfo.jvmTarget.toString()) | ||
|
||
// enable java parameter names for stronger Kotlin-Java interop and debugging | ||
javaParameters = true | ||
|
||
// consider kotlin warnings errors if not otherwise suppressed | ||
allWarningsAsErrors = true | ||
|
||
freeCompilerArgs.addAll( | ||
listOf( | ||
// enable strict nullability checking and integration with pkl's own annotations | ||
"-Xjsr305=strict", | ||
"-Xjsr305=@org.pkl.core.util.Nullable:strict", | ||
"-Xjsr305=@org.pkl.core.util.Nonnull:strict", | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after #900, the new compilerOptions { ... }
Kotlin Gradle Plugin syntax can be used and the old kotlinOptions
DSL is deprecated.
-
javaParameters
: Allows Java reflection downstream on method parameters, and improves debugging by embedding parameter names within Kotlin bytecode -
allWarningsAsErrors
: Considers Kotlin compiler warnings as errors. Enabling this had no effect, as the Pkl project already essentially enforces this by convention. -
-Xjsr305=@...:strict
: Instructskotlinc
to consider Pkl's nullability annotations as authoritative. Java/Kotlin interop will respect these annotations such that Java types behave asT?
if annotated with@Nullable
, andT
if annotated with@Nonnull
. Enabling this had no negative impact.
@Suppress("DEPRECATION") | ||
private fun parseAsciidoc(docDescriptor: Descriptor.Path, selectors: List<UniqueIdSelector>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certain methods of AbstractDeque
produce warnings, but they are just used here in tests, and the warnings involved describe missed optimizations. So I have suppressed them.
Signed-off-by: Sam Gammon <sam@elide.dev>
|
||
plugins { | ||
id("pklJavaLibrary") | ||
|
||
id("org.jetbrains.kotlinx.binary-compatibility-validator") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added Kotlin ABI checking so that the Kotlin version change and JDK 21 change can be tested (w.r.t. library use) before release.
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,
AbstractTruffleException
andTruffleFeature
) have moved to the neworg.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 andjava -jar ...
executions.Flags and JSR305 compat for
kotlinc
: Applies-Xjsr305=strict
support for Pkl's own annotations,org.pkl.core.util.Nullable
andorg.pkl.core.util.Nonnull
. Java parameter names are retained in Kotlin bytecode, enabling smoother Java/Kotlin interop and debugging.Kotlin ABI Check: Checks Kotlin public library symbols for drift. Run
apiCheck
to make sure a change does not break downstream Java/Kotlin library consumers; runapiDump
to re-seal public API lockfiles.Known Issues
pkl-gradle
)--add-exports=...
Pre-merge Checklist
Changelog
-PnativeArch=native
to build with-march=native
jsr305
compat forkotlinc
Unsafe.ensureInitialized
)24.0.0
--add-modules=jdk.unsupported
where neededgu
tool for modern graalvm versions24.1.2