Skip to content

Commit

Permalink
Try to get newer JDKs to work
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl committed Aug 5, 2024
1 parent dc2c95d commit 62b7703
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ jobs:
with:
java-version: ${{ matrix.java.version }}
distribution: 'temurin'
- name: Set up JDK 21 on an experimental platform
if: matrix.java.experimental
uses: actions/setup-java@v4
with:
# Install JDK 21 second, to make it the default on which gradle runs.
# This unfortunately also means that all tests run on JDK 21 instead of the newer version.
java-version: 21
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
Expand All @@ -100,6 +108,9 @@ jobs:

- name: Run test script checker/bin-devel/test-${{ matrix.script }}
run: ./checker/bin-devel/test-${{ matrix.script }}.sh
# Set the compiler version to use, allowing us to e.g. run Java 23 while gradle does not work
# on Java 23 yet. This only tests the compiler, it does not use that version to run the tests.
env: ORG_GRADLE_PROJECT_useJdkCompiler=${{ matrix.java.version }}

# Sanity tests on Windows and MacOS.
otheros:
Expand Down
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,17 @@ allprojects {
// Add standard javac options
tasks.withType(JavaCompile) { compilationTask ->
dependsOn(':installGitHooks')
boolean jdk21Compiler = project.getProperties().getOrDefault('useJdk21Compiler', false)
if (!isJava8 && jdk21Compiler) {
// This uses the Java 21 compiler to compile all code, like we do for a release.
int useJdkCompiler = project.getProperties().getOrDefault('useJdkCompiler', 21)
boolean useToolchains = (JavaVersion.current() != useJdkCompiler)
if (!isJava8 && useToolchains) {
// This uses the requested Java compiler to compile all code.
// If no version is requested, we use Java 21, like we do for a release.
// CI test test-cftests-junit-jdk21 then runs the JUnit tests on the different JDK versions,
// to ensure there is no version mismatch between compiled-against javac API and runtime API.
// https://docs.gradle.org/current/userguide/toolchains.html
// This property is final on Java 8, so don't set it then.
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(useJdkCompiler)
}
}

Expand Down Expand Up @@ -459,7 +461,7 @@ allprojects {
// warnings are suppressible with a "// fall through" comment.
// -classfile: classgraph jar file and https://bugs.openjdk.org/browse/JDK-8190452
String lint = '-Xlint:-options,-fallthrough,-classfile'
if (isJava21plus || jdk21Compiler) {
if (useJdkCompiler >= 21) {
// TODO: Ignore this-escape for now, we may want to review and suppress each one later.
lint +=',-this-escape'
}
Expand Down
2 changes: 1 addition & 1 deletion checker/bin-devel/test-cftests-junit-jdk21.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo "SHELLOPTS=${SHELLOPTS}"

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# shellcheck disable=SC1090# In newer shellcheck than 0.6.0, pass: "-P SCRIPTDIR" (literally)
export ORG_GRADLE_PROJECT_useJdk21Compiler=true
export ORG_GRADLE_PROJECT_useJdkCompiler=21
source "$SCRIPTDIR"/clone-related.sh


Expand Down

0 comments on commit 62b7703

Please sign in to comment.