apache/iceberg · error · GradleException
The JMH benchmarks must be run with JDK 17 or JDK 21
Error message
The JMH benchmarks must be run with JDK 17 or JDK 21
What it means
jmh.gradle validates that the JDK used to run JMH benchmarks is 17 or 21. The benchmark harness and its bytecode/toolchain expectations only support these two LTS versions, so any other JDK fails fast with this GradleException before benchmarks are configured.
Source
Thrown at jmh.gradle:21
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
if (jdkVersion != '17' && jdkVersion != '21') {
throw new GradleException("The JMH benchmarks must be run with JDK 17 or JDK 21")
}
def flinkVersions = (System.getProperty("flinkVersions") != null ? System.getProperty("flinkVersions") : System.getProperty("defaultFlinkVersions")).split(",")
def sparkVersions = (System.getProperty("sparkVersions") != null ? System.getProperty("sparkVersions") : System.getProperty("defaultSparkVersions")).split(",")
def scalaVersion = System.getProperty("scalaVersion") != null ? System.getProperty("scalaVersion") : System.getProperty("defaultScalaVersion")
def jmhProjects = [project(":iceberg-core"), project(":iceberg-data")]
if (flinkVersions.contains("1.20")) {
jmhProjects.add(project(":iceberg-flink:iceberg-flink-1.20"))
}
if (flinkVersions.contains("2.1")) {
jmhProjects.add(project(":iceberg-flink:iceberg-flink-2.1"))
}
if (flinkVersions.contains("2.2")) {
jmhProjects.add(project(":iceberg-flink:iceberg-flink-2.2"))
}View on GitHub (pinned to 86d9c8fc54)
Solutions
- Run the benchmark tasks with JDK 17 or JDK 21 by setting JAVA_HOME or org.gradle.java.home accordingly.
- If using Gradle toolchains, set the JVM toolchain version to 17 or 21 for the JMH subprojects.
- Upgrade or rebuild the container/CI image to one that ships JDK 17 or 21.
Example fix
// before JAVA_HOME=jdk-11 ./gradlew :iceberg-data:jmh // after JAVA_HOME=jdk-21 ./gradlew :iceberg-data:jmh
Defensive patterns
Strategy: validation
Validate before calling
JAVA_VERSION=$(java -version 2>&1 | head -1); [[ "$JAVA_VERSION" == *'"17.'* || "$JAVA_VERSION" == *'"21.'* ]] || echo 'JMH requires JDK 17 or 21'
Prevention
- Use JDK 17 or 21 containers/images for benchmark runs.
- Set org.gradle.java.home in your local gradle.properties to a 17/21 JDK.
- Verify the JDK before long benchmark sessions to avoid wasted runs.
When it happens
Trigger: Running any JMH task (e.g. ./gradlew :iceberg-core:jmh or -Pjmh...) with jdkVersion set to something other than 17 or 21, such as JDK 11 or JDK 8.
Common situations: Old CI images with JDK 11 default; local machine with JDK 8 for legacy work; running benchmarks inside a container pinned to an unsupported JDK.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- Releases must be built with Java 17
- This build must be run with JDK 17 or 21 but was executed wi
- Neither version.txt nor git version exists:
- Neither version.txt nor git version exists
- Expected a Spark/Scala version combination in Gradle project
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/f7b0cffb0a0c8c77.
Report an issue: GitHub.