You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2026/10/03 10:58:37 UTC

(calcite) branch main updated (76af08e3bb -> fe1c46d2be)

This is an automated email from the ASF dual-hosted git repository.

vlsi pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


    from 76af08e3bb [CALCITE-5121] Rethrow RuntimeException as SQLException in Driver#onConnectionInit
     new 8dcfd12802 [CALCITE-4553] Use Gradle toolchain to compile Calcite with JDK 25 and --release 8
     new fe1c46d2be [CALCITE-4553] Document the JDK that compiles Calcite

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/main.yml | 107 +++++++++++++++++++++++++++++++++------------
 build.gradle.kts           |  10 ++++-
 gradle.properties          |   1 +
 settings.gradle.kts        |   2 +
 site/_docs/howto.md        |  42 ++++++++++++++++--
 site/develop/index.md      |  16 +++----
 6 files changed, 136 insertions(+), 42 deletions(-)


(calcite) 02/02: [CALCITE-4553] Document the JDK that compiles Calcite

Posted by vl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vlsi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit fe1c46d2beff6e1edcc050ffbb03df1724adbaf3
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Fri Sep 25 11:14:07 2026 +0300

    [CALCITE-4553] Document the JDK that compiles Calcite
    
    The build compiles with the jdkBuildVersion toolchain (JDK 25 by default)
    and --release 8, but howto.md listed only the JDKs that run Gradle, and
    develop/index.md still asked for JDK 8u220 because of javac 8 bugs with
    type annotations. Neither page said that Gradle on Java 8 cannot download
    the build JDK, and the Error Prone and Checker Framework commands failed
    on JDK 25 as written.
    
    Add a howto.md section on the build JDK with the error Gradle prints
    when it is missing, point the build prerequisites and the release steps
    to it, and pass -PjdkBuildVersion=11 in the Error Prone and Checker
    Framework commands. Drop the JDK 8u202 and CALCITE-6616 notes: both
    were about javac 8 or 21 compiling the code.
    
    Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
---
 site/_docs/howto.md   | 42 ++++++++++++++++++++++++++++++++++++++----
 site/develop/index.md | 16 +++++++---------
 2 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/site/_docs/howto.md b/site/_docs/howto.md
index 8be84ea2dd..1592e34006 100644
--- a/site/_docs/howto.md
+++ b/site/_docs/howto.md
@@ -33,6 +33,8 @@ ## Building from a source distribution
 
 Prerequisite is Java (JDK 8, 11, 17, 21 or 24)
 and Gradle (version 8.14.4) on your path.
+The build compiles the code with JDK 25;
+see [the JDK that compiles Calcite](#the-jdk-that-compiles-calcite).
 
 Unpack the source distribution `.tar.gz` file,
 `cd` to the root directory of the unpacked source,
@@ -52,6 +54,8 @@ ## Building from Git
 
 Prerequisites are git
 and Java (JDK 8, 11, 17, 21 or 24) on your path.
+The build compiles the code with JDK 25;
+see [the JDK that compiles Calcite](#the-jdk-that-compiles-calcite).
 
 Create a local copy of the GitHub repository,
 `cd` to its root directory,
@@ -76,6 +80,35 @@ ## Building from Git
 [Running tests](#running-tests) describes how to run more or fewer
 tests.
 
+## The JDK that compiles Calcite
+
+Gradle compiles Calcite with JDK 25 (the `jdkBuildVersion` property selects it)
+and passes `--release 8` to `javac`,
+so the classes run on Java 8 and use only the Java 8 API.
+Tests, javadoc, and other tasks that run Java use the JDK that runs Gradle,
+so `JAVA_HOME` selects the JDK the tests run on.
+
+Gradle finds JDK 25 when it is installed in a standard location,
+or in a directory listed in `org.gradle.java.installations.paths`
+(see [toolchain auto-detection](https://docs.gradle.org/8.14.4/userguide/toolchains.html#sec:auto_detection)).
+Otherwise, Gradle downloads it.
+The download works only when Gradle runs on Java 11 or later,
+so if you run Gradle on Java 8, install JDK 25 yourself.
+Without it, compilation fails with:
+
+{% highlight text %}
+Cannot find a Java installation on your machine (...) matching: {languageVersion=25, vendor=any vendor, implementation=vendor-specific, nativeImageCapable=false}. Some toolchain resolvers had internal failures: foojay (Requesting vendor list failed: error code: 1010
+{% endhighlight %}
+
+* `-PjdkBuildVersion=N` (integer, default `25`) selects the major version of
+  the JDK that compiles the code.
+  Error Prone 2.5.1 fails on JDK 25 with
+  `IllegalAccessError: class com.google.errorprone.JavacErrorDescriptionListener ... cannot access class com.sun.tools.javac.tree.JCTree$JCCompilationUnit`,
+  so run it and the Checker Framework with `-PjdkBuildVersion=11`, as CI does.
+* `-Porg.gradle.java.installations.auto-download=false`, also accepted in
+  `gradle.properties`, makes the build fail instead of downloading a JDK.
+  The error then ends with `Toolchain auto-provisioning is not enabled.`
+
 ## Gradle vs the Gradle Wrapper
 
 Calcite uses the Gradle Wrapper to make a consistent build environment.
@@ -125,7 +158,7 @@ ## Running tests
 $ ./gradlew test # execute tests
 $ ./gradlew style # update code formatting (for auto-correctable cases) and verify style
 $ ./gradlew autostyleCheck checkstyleAll # report code style violations
-$ ./gradlew -PenableErrorprone classes # verify Java code with Error Prone compiler, requires Java 11
+$ ./gradlew -PenableErrorprone -PjdkBuildVersion=11 classes # verify Java code with Error Prone compiler on JDK 11
 {% endhighlight %}
 
 You can use `./gradlew assemble` to build the artifacts and skip all tests and verifications.
@@ -705,7 +738,8 @@ ## Making a snapshot
 
 Before you start:
 
-* Make sure you are using JDK 8. Note: you need Java 8u202 or later in case you use OpenJDK-based Java.
+* Make sure you are using JDK 8, and that JDK 25 is installed
+  (see [the JDK that compiles Calcite](#the-jdk-that-compiles-calcite)).
 * Make sure build and tests succeed with `-Dcalcite.test.db=hsqldb` (the default)
 
 {% highlight bash %}
@@ -733,8 +767,8 @@ ## Making a release candidate
   Report to [private@calcite.apache.org](mailto:private@calcite.apache.org)
   if new critical vulnerabilities are found among dependencies.
   The task requires a JDK 11 or later so it doesn't appear when using older versions.
-* Make sure you are using JDK 8 for all subsequent steps. (Compiling with JDK 21 causes
-  [[CALCITE-6616](https://issues.apache.org/jira/browse/CALCITE-6616)].)
+* Make sure you are using JDK 8 for all subsequent steps, and that JDK 25 is installed
+  (see [the JDK that compiles Calcite](#the-jdk-that-compiles-calcite)).
 * Check that `README` and `site/_docs/howto.md` have the correct version number.
 * Check that `site/_docs/howto.md` has the correct Gradle version.
 * Check that `NOTICE` has the current copyright year.
diff --git a/site/develop/index.md b/site/develop/index.md
index de3221609a..b0fc04b75b 100644
--- a/site/develop/index.md
+++ b/site/develop/index.md
@@ -41,14 +41,9 @@ ## Source code
 ## Download source, build, and run tests
 
 Prerequisites are Git,
-and Java (JDK 8u220 or later, 11 preferred) on your path.
-
-Note: early OpenJDK 1.8 versions (e.g. versions before 1.8u202) are known to have issues with
-producing bytecode for type annotations (see [JDK-8187805](https://bugs.openjdk.java.net/browse/JDK-8187805),
-[JDK-8187805](https://bugs.openjdk.java.net/browse/JDK-8187805),
-[JDK-8210273](https://bugs.openjdk.java.net/browse/JDK-8210273),
-[JDK-8160928](https://bugs.openjdk.java.net/browse/JDK-8160928),
-[JDK-8144185](https://bugs.openjdk.java.net/browse/JDK-8144185) ), so make sure you use up to date Java.
+and Java (JDK 8, 11, 17, 21 or 24) on your path.
+The build compiles the code with JDK 25; see
+[the JDK that compiles Calcite]({{ site.baseurl }}/docs/howto.html#the-jdk-that-compiles-calcite).
 
 Create a local copy of the Git repository, `cd` to its root directory,
 then build using Gradle:
@@ -236,7 +231,10 @@ ## Null safety
 
 To execute the Checker Framework locally please use the following command:
 
-    ./gradlew -PenableCheckerframework :linq4j:classes :core:classes
+    ./gradlew -PjdkBuildVersion=11 -PenableCheckerframework :linq4j:classes :core:classes
+
+`-PjdkBuildVersion=11` compiles with JDK 11, as CI does; see
+[the JDK that compiles Calcite]({{ site.baseurl }}/docs/howto.html#the-jdk-that-compiles-calcite).
 
 Here's a small introduction to null-safe programming:
 


(calcite) 01/02: [CALCITE-4553] Use Gradle toolchain to compile Calcite with JDK 25 and --release 8

Posted by vl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vlsi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 8dcfd128025ebb47ae3a2a7dad6ee6af29e30bf0
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Mon Sep 21 19:43:38 2026 +0300

    [CALCITE-4553] Use Gradle toolchain to compile Calcite with JDK 25 and --release 8
    
    Previously javac came from the JDK that ran Gradle, so the compiler version
    varied with each CI job and each developer's JAVA_HOME, and only
    sourceCompatibility/targetCompatibility 1.8 kept the bytecode at Java 8
    without checking the JDK 8 API. Older javac versions also have known bugs
    with type annotations, which Calcite uses for nullability.
    
    JavaCompile tasks now take their compiler from a toolchain,
    jdkBuildVersion (default 25), and pass --release 8, which also rejects
    calls to APIs newer than Java 8. Tests, javadoc, and JavaExec tasks still
    run on the JDK that runs Gradle.
    
    The foojay resolver downloads the toolchain when no matching JDK is
    installed. It stays at 0.10.0 because 1.0.0 requires Gradle to run on
    Java 17, and CI still runs Gradle on Java 8 and 11. When Gradle runs on
    Java 8, the download fails anyway: api.foojay.io answers the Java 8
    User-Agent with "error code: 1010", so the build JDK must be installed.
    
    CI installs JDK 25 next to the JDK each job tests with, and sets
    org.gradle.java.installations.auto-download=false, so a build fails
    instead of silently compiling with a JDK that foojay downloaded.
    The ErrorProne and Checker Framework jobs pass -PjdkBuildVersion=11:
    ErrorProne 2.5.1 fails on JDK 25 with
    "IllegalAccessError: class com.google.errorprone.JavacErrorDescriptionListener
    ... cannot access class com.sun.tools.javac.tree.JCTree$JCCompilationUnit".
    
    Co-Authored-By: Claude Opus 5 <no...@anthropic.com>
---
 .github/workflows/main.yml | 107 +++++++++++++++++++++++++++++++++------------
 build.gradle.kts           |  10 ++++-
 gradle.properties          |   1 +
 settings.gradle.kts        |   2 +
 4 files changed, 91 insertions(+), 29 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 37488ffc7d..bb3d609db5 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -58,10 +58,12 @@ jobs:
     - uses: actions/checkout@v7
       with:
         fetch-depth: 50
-    - name: 'Set up JDK 8'
+    - name: 'Set up JDK 25 for compilation and JDK 8 for tests'
       uses: actions/setup-java@v6
       with:
-        java-version: 8
+        java-version: |
+          25
+          8
         distribution: 'zulu'
     - uses: burrunan/gradle-cache-action@v1
       name: Test
@@ -69,6 +71,8 @@ jobs:
         job-id: jdk${{ matrix.jdk }}
         remote-build-cache-proxy-enabled: false
         arguments: --scan --no-parallel --no-daemon build javadoc
+        properties: |
+          org.gradle.java.installations.auto-download=false
     - name: 'sqlline and sqllsh'
       env:
         JAVA_OPTS: "-Dcalcite.model.classes.allowed=org.apache."
@@ -89,10 +93,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 17'
+      - name: 'Set up JDK 25 for compilation and JDK 17 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 17
+          java-version: |
+            25
+            17
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -100,6 +106,8 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon build
+          properties: |
+            org.gradle.java.installations.auto-download=false
       - name: 'sqlline and sqllsh'
         env:
           JAVA_OPTS: "-Dcalcite.model.classes.allowed=org.apache."
@@ -120,10 +128,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 21'
+      - name: 'Set up JDK 25 for compilation and JDK 21 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 21
+          java-version: |
+            25
+            21
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -131,6 +141,8 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon build
+          properties: |
+            org.gradle.java.installations.auto-download=false
       - name: 'sqlline and sqllsh'
         env:
           JAVA_OPTS: "-Dcalcite.model.classes.allowed=org.apache."
@@ -153,10 +165,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 8'
+      - name: 'Set up JDK 25 for compilation and JDK 8 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 8
+          java-version: |
+            25
+            8
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -164,6 +178,8 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MIN }} build
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-jdk8-latest-guava-tz:
     name: 'Linux (JDK 8, latest Guava, America/New_York Timezone)'
@@ -174,10 +190,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 8'
+      - name: 'Set up JDK 25 for compilation and JDK 8 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 8
+          java-version: |
+            25
+            8
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -185,6 +203,8 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MAX }} tasks build
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-jdk11-tz:
     name: 'Linux (JDK 11, Pacific/Chatham Timezone)'
@@ -195,10 +215,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 11'
+      - name: 'Set up JDK 25 for compilation and JDK 11 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 11
+          java-version: |
+            25
+            11
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -206,6 +228,8 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon build
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-jdk17:  # LTS JDK version, don't remove until EOL
     name: 'Linux (JDK 17)'
@@ -214,10 +238,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 17'
+      - name: 'Set up JDK 25 for compilation and JDK 17 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 17
+          java-version: |
+            25
+            17
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -225,6 +251,8 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} build
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-jdk121:  # LTS JDK version, don't remove until EOL
     name: 'Linux (JDK 21)'
@@ -233,10 +261,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 21'
+      - name: 'Set up JDK 25 for compilation and JDK 21 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 21
+          java-version: |
+            25
+            21
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -244,6 +274,8 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} build
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-jdk24: # latest JDK version supported by ForbiddenAPIs plugin, keep this updated (see https://jdk.java.net/)
     name: 'Linux (JDK 24)'
@@ -252,10 +284,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 24'
+      - name: 'Set up JDK 25 for compilation and JDK 24 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 24
+          java-version: |
+            25
+            24
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -263,15 +297,19 @@ jobs:
           job-id: jdk${{ matrix.jdk }}
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} tasks build
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-avatica:
     name: 'Linux (JDK 11, Avatica main)'
     runs-on: ubuntu-latest
     steps:
-    - name: 'Set up JDK 11'
+    - name: 'Set up JDK 25 for compilation and JDK 11 for tests'
       uses: actions/setup-java@v6
       with:
-        java-version: 11
+        java-version: |
+          25
+          11
         distribution: 'zulu'
     - name: 'Clone Avatica to Maven Local repository'
       run: |
@@ -297,6 +335,7 @@ jobs:
         execution-only-caches: true
         arguments: --scan --no-parallel --no-daemon build javadoc
         properties: |
+          org.gradle.java.installations.auto-download=false
           calcite.avatica.version=1.0.0-dev-main-SNAPSHOT
           enableMavenLocal=
 
@@ -307,10 +346,12 @@ jobs:
       - uses: actions/checkout@v7
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 21'
+      - name: 'Set up JDK 25 for compilation and JDK 21 for tests'
         uses: actions/setup-java@v6
         with:
-          java-version: 21
+          java-version: |
+            25
+            21
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -318,6 +359,8 @@ jobs:
           job-id: jdk21
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon build javadoc
+          properties: |
+            org.gradle.java.installations.auto-download=false
       - name: 'sqlline and sqllsh'
         env:
           JAVA_OPTS: "-Dcalcite.model.classes.allowed=org.apache."
@@ -348,7 +391,9 @@ jobs:
           job-id: errprone
           remote-build-cache-proxy-enabled: false
           # ErrorProne checks for Beta APIs, so use the latest supported Guava version
-          arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MAX }} -PenableErrorprone classes
+          arguments: --scan --no-parallel --no-daemon -PjdkBuildVersion=11 -Pguava.version=${{ env.GUAVA_MAX }} -PenableErrorprone classes
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-checkerframework:
     name: 'CheckerFramework (JDK 11)'
@@ -367,7 +412,9 @@ jobs:
         with:
           job-id: checkerframework-jdk11
           remote-build-cache-proxy-enabled: false
-          arguments: --scan --no-parallel --no-daemon -PenableCheckerframework :linq4j:classes :core:classes :server:classes
+          arguments: --scan --no-parallel --no-daemon -PjdkBuildVersion=11 -PenableCheckerframework :linq4j:classes :core:classes :server:classes
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-checkerframework-oldest-guava:
     name: 'CheckerFramework (JDK 11, oldest Guava)'
@@ -386,16 +433,20 @@ jobs:
         with:
           job-id: checkerframework-jdk11
           remote-build-cache-proxy-enabled: false
-          arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MIN }} -PenableCheckerframework :linq4j:classes :core:classes :server:classes
+          arguments: --scan --no-parallel --no-daemon -PjdkBuildVersion=11 -Pguava.version=${{ env.GUAVA_MIN }} -PenableCheckerframework :linq4j:classes :core:classes :server:classes
+          properties: |
+            org.gradle.java.installations.auto-download=false
 
   linux-druid:
     name: 'Druid Tests'
     runs-on: ubuntu-latest
     steps:
-    - name: 'Set up JDK 17'
+    - name: 'Set up JDK 25 for compilation and JDK 17 for tests'
       uses: actions/setup-java@v6
       with:
-        java-version: 17
+        java-version: |
+          25
+          17
         distribution: 'zulu'
     - name: 'Checkout Druid dataset'
       uses: actions/checkout@v7
@@ -430,3 +481,5 @@ jobs:
         job-id: Druid8
         remote-build-cache-proxy-enabled: false
         arguments: --scan --no-parallel --no-daemon :druid:test -Dcalcite.test.druid=true
+        properties: |
+          org.gradle.java.installations.auto-download=false
diff --git a/build.gradle.kts b/build.gradle.kts
index 4a45616720..6d5c4747a9 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -91,6 +91,8 @@ fun reportsForHumans() = !(System.getenv()["CI"]?.toBoolean() ?: false)
 val enableMavenLocal by props()
 val enableGradleMetadata by props()
 val werror by props(true) // treat javac warnings as errors
+// JDK that compiles the code; the bytecode still targets Java 8 via --release 8
+val jdkBuildVersion = props.int("jdkBuildVersion", 25)
 // Inherited from stage-vote-release-plugin: skipSign, useGpgCmd
 // Inherited from gradle-extensions-plugin: slowSuiteLogThreshold=0L, slowTestLogThreshold=2000L
 
@@ -872,8 +874,12 @@ fun com.github.autostyle.gradle.BaseFormatExtension.license() {
             }
 
             configureEach<JavaCompile> {
-                inputs.property("java.version", System.getProperty("java.version"))
-                inputs.property("java.vm.version", System.getProperty("java.vm.version"))
+                javaCompiler.set(
+                    project.the<JavaToolchainService>().compilerFor {
+                        languageVersion.set(JavaLanguageVersion.of(jdkBuildVersion))
+                    }
+                )
+                options.release.set(8)
                 options.encoding = "UTF-8"
                 options.compilerArgs.add("-Xlint:deprecation")
                 // JDK 1.8 is deprecated https://bugs.openjdk.org/browse/JDK-8173605
diff --git a/gradle.properties b/gradle.properties
index 2027c6f82a..2f9bed80d2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -59,6 +59,7 @@ org.owasp.dependencycheck.version=12.2.2
 org.sonarqube.version=3.5.0.2730
 com.gradle.develocity.version=4.5.1
 com.gradle.common-custom-user-data-gradle-plugin.version=2.8.0
+org.gradle.toolchains.foojay-resolver-convention.version=0.10.0
 
 
 # For now, we use Kotlin for tests only, so we don't want to include kotlin-stdlib dependency to the runtimeClasspath
diff --git a/settings.gradle.kts b/settings.gradle.kts
index fbc3502a7c..c0138f48ce 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -43,6 +43,7 @@ fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version ke
             idv("org.owasp.dependencycheck")
         }
         idv("org.sonarqube")
+        idv("org.gradle.toolchains.foojay-resolver-convention")
         kotlin("jvm") version "kotlin".v()
     }
     if (extra.has("enableMavenLocal") && extra["enableMavenLocal"].toString().ifBlank { "true" }.toBoolean()) {
@@ -54,6 +55,7 @@ fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version ke
 }
 
 plugins {
+    id("org.gradle.toolchains.foojay-resolver-convention")
     id("com.gradle.develocity")
     id("com.gradle.common-custom-user-data-gradle-plugin")
 }