mirror of
https://github.com/apple/pkl.git
synced 2026-07-15 17:42:46 +02:00
Use javac -release and kotlinc -Xjdk-release (#1080)
The change ensures the generated bytecode adheres to the APIs for the target Java release. Previously, only sourceCompatibility and targetCompatibility were used, and they might cause issues like NoSuchMethodError when a newer javac compiles with -target older_release. Note: it is good to use a new an up to date javac to avoid issues in the compiler itself, so having a proper `-release ..` configuration is vital. See https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderr
This commit is contained in:
committed by
GitHub
parent
a19e6bf684
commit
7d50c46c29
@@ -35,16 +35,18 @@ dependencies {
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.toVersion(toolchainVersion)
|
||||
targetCompatibility = JavaVersion.toVersion(toolchainVersion)
|
||||
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(toolchainVersion)
|
||||
vendor = JvmVendorSpec.ADOPTIUM
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach { options.release = toolchainVersion }
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(toolchainVersion)
|
||||
compilerOptions { jvmTarget = JvmTarget.fromTarget(toolchainVersion.toString()) }
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.fromTarget(toolchainVersion.toString())
|
||||
freeCompilerArgs.add("-Xjdk-release=$toolchainVersion")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user