Skip to content

Commit

Permalink
chore: Bump the compiler, runtime, and test runtime version to Java 21
Browse files Browse the repository at this point in the history
Fixes #3997
  • Loading branch information
devinrsmith committed Nov 6, 2024
1 parent 7657ff5 commit 2063b5e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ plugins {
id 'java'
}

def compilerVersion = Integer.parseInt((String)project.findProperty('compilerVersion') ?: '11')
def compilerVersion = Integer.parseInt((String)project.findProperty('compilerVersion') ?: '21')
def compilerVendor = project.hasProperty('compilerVendor') ? JvmVendorSpec.matching((String)project.property('compilerVendor')): null

def languageLevel = Integer.parseInt((String)project.findProperty('languageLevel') ?: '11')
def runtimeVersion = Integer.parseInt((String)project.findProperty('runtimeVersion') ?: '11')
def runtimeVersion = Integer.parseInt((String)project.findProperty('runtimeVersion') ?: '21')
def runtimeVendor = project.hasProperty('runtimeVendor') ? JvmVendorSpec.matching((String)project.property('runtimeVendor')): null

def testLanguageLevel = Integer.parseInt((String)project.findProperty('testLanguageLevel') ?: '11')
def testRuntimeVersion = Integer.parseInt((String)project.findProperty('testRuntimeVersion') ?: '11')
def testRuntimeVersion = Integer.parseInt((String)project.findProperty('testRuntimeVersion') ?: '21')
def testRuntimeVendor = project.hasProperty('testRuntimeVendor') ? JvmVendorSpec.matching((String)project.property('testRuntimeVendor')): null

if (languageLevel > compilerVersion) {
Expand Down Expand Up @@ -82,10 +82,14 @@ tasks.withType(JavaCompile).configureEach {
if (name == 'compileTestJava') {
if (compilerVersion != testLanguageLevel) {
options.release.set testLanguageLevel
sourceCompatibility = testLanguageLevel
targetCompatibility = testLanguageLevel
}
} else {
if (compilerVersion != languageLevel) {
options.release.set languageLevel
sourceCompatibility = languageLevel
targetCompatibility = languageLevel
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions clock-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ dependencies {

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['--add-exports', 'java.base/jdk.internal.misc=ALL-UNNAMED']
// Explicitly set the source compatibility so gradle will invoke javac with `-source 11` instead of `--release`
sourceCompatibility = 11
// Explicitly unset release so gradle will invoke javac with `-source <languageLevel> -target <languageLevel>`
// instead of `--release <languageLevel>`, which would otherwise produce
// > error: exporting a package from system module java.base is not allowed with --release
options.release.unset()
}

tasks.withType(Javadoc).configureEach {
Expand Down
6 changes: 4 additions & 2 deletions hotspot-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ dependencies {

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['--add-exports', 'java.management/sun.management=ALL-UNNAMED']
// Explicitly set the source compatibility so gradle will invoke javac with `-source 11` instead of `--release`
sourceCompatibility = 11
// Explicitly unset release so gradle will invoke javac with `-source <languageLevel> -target <languageLevel>`
// instead of `--release <languageLevel>`, which would otherwise produce
// > error: exporting a package from system module java.management is not allowed with --release
options.release.unset()
}

tasks.withType(Javadoc).configureEach {
Expand Down

0 comments on commit 2063b5e

Please sign in to comment.