From 024229f419e893664a0fea9fa010ea906b1e38db Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Wed, 28 Oct 2026 15:38:03 -0700 Subject: [PATCH 1/3] [SPARK-60669][BUILD][INFRA][DOC] Drop Java 17 Support --- .github/workflows/benchmark.yml | 5 ++--- .github/workflows/build_and_test.yml | 2 +- .github/workflows/build_codegen_jdk.yml | 4 ++-- .github/workflows/build_coverage.yml | 2 +- .github/workflows/build_maven.yml | 2 +- .github/workflows/build_non_ansi.yml | 4 ++-- .github/workflows/build_python_3.11.yml | 2 +- .github/workflows/build_python_3.12_classic_only.yml | 2 +- .github/workflows/build_python_3.12_pandas_3.yml | 2 +- .github/workflows/build_python_3.13.yml | 2 +- .github/workflows/build_python_3.14.yml | 2 +- .github/workflows/build_python_3.14_nogil.yml | 2 +- .github/workflows/build_python_3.15.yml | 2 +- .github/workflows/build_python_connect.yml | 2 +- .github/workflows/build_python_connect40.yml | 2 +- .github/workflows/build_python_minimum.yml | 2 +- .github/workflows/build_rockdb_as_ui_backend.yml | 4 ++-- .github/workflows/build_sparkr_window.yml | 4 ++-- .github/workflows/build_uds.yml | 4 ++-- .github/workflows/maven_test.yml | 2 +- .github/workflows/pages.yml | 4 ++-- .github/workflows/publish_snapshot.yml | 10 ++++++++-- .github/workflows/python_hosted_runner_test.yml | 2 +- README.md | 2 +- docs/building-spark.md | 2 +- docs/index.md | 2 +- docs/security.md | 10 +++++----- pom.xml | 6 +++--- python/docs/source/getting_started/install.rst | 2 +- 29 files changed, 49 insertions(+), 44 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 3140cb054e579..17fbbbca59416 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -28,11 +28,10 @@ on: default: '*' jdk: type: choice - description: 'JDK version: 17, 21, or 25' + description: 'JDK version: 21 or 25' required: true - default: '17' + default: '21' options: - - '17' - '21' - '25' scala: diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 126288a544b3d..234f38f48da6d 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -25,7 +25,7 @@ on: java: required: false type: string - default: 17 + default: 21 branch: description: Branch to run the build against required: false diff --git a/.github/workflows/build_codegen_jdk.yml b/.github/workflows/build_codegen_jdk.yml index 3df5f94ce4845..5f49d740b9783 100644 --- a/.github/workflows/build_codegen_jdk.yml +++ b/.github/workflows/build_codegen_jdk.yml @@ -25,7 +25,7 @@ # javac is slower than Janino, so this runs on its own schedule rather than on # every push, skips the jobs that do not compile generated code (docs, lint, buf, # ui), and raises the timeout of the three jobs that no longer fit their default. -name: "Build / Codegen JDK backend (master, Scala 2.13, JDK 17)" +name: "Build / Codegen JDK backend (master, Scala 2.13, JDK 21)" on: schedule: @@ -40,7 +40,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 # See SPARK-57411 for the measurements behind these three. diff --git a/.github/workflows/build_coverage.yml b/.github/workflows/build_coverage.yml index 9db5f5e5f9716..d792753e2aa33 100644 --- a/.github/workflows/build_coverage.yml +++ b/.github/workflows/build_coverage.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_maven.yml b/.github/workflows/build_maven.yml index 2e40b70a6500b..ee38a36579c51 100644 --- a/.github/workflows/build_maven.yml +++ b/.github/workflows/build_maven.yml @@ -17,7 +17,7 @@ # under the License. # -name: "Build / Maven (Scala 2.13, JDK 17)" +name: "Build / Maven (Scala 2.13, JDK 21)" on: schedule: diff --git a/.github/workflows/build_non_ansi.yml b/.github/workflows/build_non_ansi.yml index c19081c204fd6..14daac8eb2e69 100644 --- a/.github/workflows/build_non_ansi.yml +++ b/.github/workflows/build_non_ansi.yml @@ -17,7 +17,7 @@ # under the License. # -name: "Build / Non-ANSI (JDK 17, Scala 2.13)" +name: "Build / Non-ANSI (JDK 21, Scala 2.13)" on: schedule: @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_3.11.yml b/.github/workflows/build_python_3.11.yml index 793f1161e9486..9627e51437282 100644 --- a/.github/workflows/build_python_3.11.yml +++ b/.github/workflows/build_python_3.11.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_3.12_classic_only.yml b/.github/workflows/build_python_3.12_classic_only.yml index 2136e877e4951..d73c628c24c00 100644 --- a/.github/workflows/build_python_3.12_classic_only.yml +++ b/.github/workflows/build_python_3.12_classic_only.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_3.12_pandas_3.yml b/.github/workflows/build_python_3.12_pandas_3.yml index 570fddfd11a5b..f8d1cf915ced8 100644 --- a/.github/workflows/build_python_3.12_pandas_3.yml +++ b/.github/workflows/build_python_3.12_pandas_3.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_3.13.yml b/.github/workflows/build_python_3.13.yml index fea1d786bc6b1..281225b155025 100644 --- a/.github/workflows/build_python_3.13.yml +++ b/.github/workflows/build_python_3.13.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_3.14.yml b/.github/workflows/build_python_3.14.yml index 7b07b9b02b04a..559556b060086 100644 --- a/.github/workflows/build_python_3.14.yml +++ b/.github/workflows/build_python_3.14.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_3.14_nogil.yml b/.github/workflows/build_python_3.14_nogil.yml index 7e431b3d340ec..aae911398d373 100644 --- a/.github/workflows/build_python_3.14_nogil.yml +++ b/.github/workflows/build_python_3.14_nogil.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_3.15.yml b/.github/workflows/build_python_3.15.yml index 2c8535553f28e..55cba6647c34e 100644 --- a/.github/workflows/build_python_3.15.yml +++ b/.github/workflows/build_python_3.15.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_python_connect.yml b/.github/workflows/build_python_connect.yml index b3397c3ffd162..867b2d017a3dc 100644 --- a/.github/workflows/build_python_connect.yml +++ b/.github/workflows/build_python_connect.yml @@ -37,7 +37,7 @@ jobs: - name: Setup build environment uses: ./.github/actions/setup-build-env with: - java-version: '17' + java-version: '21' - name: Install Python 3.11 uses: actions/setup-python@v7 with: diff --git a/.github/workflows/build_python_connect40.yml b/.github/workflows/build_python_connect40.yml index 5e259a3a62b6f..426191fb774c2 100644 --- a/.github/workflows/build_python_connect40.yml +++ b/.github/workflows/build_python_connect40.yml @@ -39,7 +39,7 @@ jobs: - name: Setup build environment uses: ./.github/actions/setup-build-env with: - java-version: '17' + java-version: '21' - name: Install Python 3.11 uses: actions/setup-python@v7 with: diff --git a/.github/workflows/build_python_minimum.yml b/.github/workflows/build_python_minimum.yml index cb23a3db14548..9ad0f9d342e9a 100644 --- a/.github/workflows/build_python_minimum.yml +++ b/.github/workflows/build_python_minimum.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_rockdb_as_ui_backend.yml b/.github/workflows/build_rockdb_as_ui_backend.yml index 506fd28e9cc1f..0f18442285374 100644 --- a/.github/workflows/build_rockdb_as_ui_backend.yml +++ b/.github/workflows/build_rockdb_as_ui_backend.yml @@ -17,7 +17,7 @@ # under the License. # -name: "Build / RocksDB as UI Backend (JDK 17, Scala 2.13)" +name: "Build / RocksDB as UI Backend (JDK 21, Scala 2.13)" on: schedule: @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/build_sparkr_window.yml b/.github/workflows/build_sparkr_window.yml index 39b0da2c08292..aa8ff04bde253 100644 --- a/.github/workflows/build_sparkr_window.yml +++ b/.github/workflows/build_sparkr_window.yml @@ -46,11 +46,11 @@ jobs: key: build-sparkr-windows-maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} restore-keys: | build-sparkr-windows-maven-${{ runner.os }}- - - name: Install Java 17 + - name: Install Java 21 uses: actions/setup-java@v6 with: distribution: zulu - java-version: 17 + java-version: 21 - name: Install R 4.4.3 uses: r-lib/actions/setup-r@d3c5be51b12e724e68f33216ca3c148b66d5f0b6 # v2.12.1 with: diff --git a/.github/workflows/build_uds.yml b/.github/workflows/build_uds.yml index 64a97e4faa163..e23d3acea928e 100644 --- a/.github/workflows/build_uds.yml +++ b/.github/workflows/build_uds.yml @@ -17,7 +17,7 @@ # under the License. # -name: "Build / Unix Domain Socket (JDK 17, Scala 2.13)" +name: "Build / Unix Domain Socket (JDK 21, Scala 2.13)" on: schedule: @@ -32,7 +32,7 @@ jobs: uses: ./.github/workflows/build_and_test.yml if: github.repository == 'apache/spark' with: - java: 17 + java: 21 branch: master hadoop: hadoop3 envs: >- diff --git a/.github/workflows/maven_test.yml b/.github/workflows/maven_test.yml index ab720355a1e8b..b83be98f947f4 100644 --- a/.github/workflows/maven_test.yml +++ b/.github/workflows/maven_test.yml @@ -25,7 +25,7 @@ on: java: required: false type: string - default: 17 + default: 21 branch: description: Branch to run the build against required: false diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 9d0d2c06f681b..3b7e31f4bbfa2 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -56,11 +56,11 @@ jobs: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Free up disk space run: ./dev/free_disk_space_container - - name: Install Java 17 + - name: Install Java 21 uses: actions/setup-java@v6 with: distribution: zulu - java-version: 17 + java-version: 21 - name: Install dependencies for documentation generation run: | # Keep the version of Bundler here in sync with the following locations: diff --git a/.github/workflows/publish_snapshot.yml b/.github/workflows/publish_snapshot.yml index 2f10d6594f012..07b5b662b8796 100644 --- a/.github/workflows/publish_snapshot.yml +++ b/.github/workflows/publish_snapshot.yml @@ -58,12 +58,18 @@ jobs: with: distribution: temurin java-version: 8 - - name: Install Java 17 - if: matrix.branch != 'branch-3.5' + - name: Install Java 17 for branch-4.x + if: matrix.branch != 'branch-3.5' && matrix.branch != 'master' uses: actions/setup-java@v6 with: distribution: temurin java-version: 17 + - name: Install Java 21 + if: matrix.branch == 'master' + uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: 21 - name: Publish snapshot env: ASF_USERNAME: ${{ secrets.NEXUS_USER }} diff --git a/.github/workflows/python_hosted_runner_test.yml b/.github/workflows/python_hosted_runner_test.yml index 696726484a391..4159cb651c66d 100644 --- a/.github/workflows/python_hosted_runner_test.yml +++ b/.github/workflows/python_hosted_runner_test.yml @@ -25,7 +25,7 @@ on: java: required: false type: string - default: 17 + default: 21 python: required: false type: string diff --git a/README.md b/README.md index 133112688abe7..07fecf9b7777c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ and Structured Streaming for stream processing. [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Maven Central](https://img.shields.io/maven-central/v/org.apache.spark/spark-core_2.13.svg?filter=!*preview*)](https://search.maven.org/search?q=g:org.apache.spark) -[![Java](https://img.shields.io/badge/Java-17+-orange.svg)](https://adoptium.net/temurin/releases/?version=17) +[![Java](https://img.shields.io/badge/Java-21+-orange.svg)](https://adoptium.net/temurin/releases/?version=21) [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_main.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_main.yml) [![PySpark Coverage](https://codecov.io/gh/apache/spark/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/spark) [![PyPI Downloads](https://static.pepy.tech/personalized-badge/pyspark?period=month&units=international_system&left_color=black&right_color=orange&left_text=PyPI%20downloads)](https://pypi.org/project/pyspark/) diff --git a/docs/building-spark.md b/docs/building-spark.md index 4fc0724e83ffc..ebe58847d517e 100644 --- a/docs/building-spark.md +++ b/docs/building-spark.md @@ -27,7 +27,7 @@ license: | ## Apache Maven The Maven-based build is the build of reference for Apache Spark. -Building Spark using Maven requires Maven 3.9.16 and Java 17/21/25. +Building Spark using Maven requires Maven 3.9.16 and Java 21/25. Spark requires Scala 2.13; support for Scala 2.12 was removed in Spark 4.0.0. ### Setting up Maven's Memory Usage diff --git a/docs/index.md b/docs/index.md index a78f981ef85d3..6c8acb7655e5c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -34,7 +34,7 @@ source, visit [Building Spark](building-spark.html). Spark runs on both Windows and UNIX-like systems (e.g. Linux, Mac OS), and it should run on any platform that runs a supported version of Java. This should include JVMs on x86_64 and ARM64. It's easy to run locally on one machine --- all you need is to have `java` installed on your system `PATH`, or the `JAVA_HOME` environment variable pointing to a Java installation. -Spark runs on Java 17/21/25, Scala 2.13, Python 3.11+, and R 4.0+ (Deprecated). +Spark runs on Java 21/25, Scala 2.13, Python 3.11+, and R 4.0+ (Deprecated). Java 25 prior to version 25.0.3 support is deprecated as of Spark 4.2.0. When using the Scala API, it is necessary for applications to use the same version of Scala that Spark was compiled for. Since Spark 4.0.0, it's Scala 2.13. diff --git a/docs/security.md b/docs/security.md index b921598b6d6b2..b2c8f33ba19a2 100644 --- a/docs/security.md +++ b/docs/security.md @@ -570,8 +570,8 @@ replaced with one of the above namespaces. A comma-separated list of ciphers. The specified ciphers must be supported by JVM.
The reference list of protocols can be found in the "JSSE Cipher Suite Names" section - of the Java security guide. The list for Java 17 can be found at - this + of the Java security guide. The list for Java 21 can be found at + this page.
Note: If not set, the default cipher suite for the JRE will be used. @@ -614,8 +614,8 @@ replaced with one of the above namespaces. TLS protocol to use. The protocol must be supported by JVM.
The reference list of protocols can be found in the "Additional JSSE Standard Names" - section of the Java security guide. For Java 17, the list can be found at - this + section of the Java security guide. For Java 21, the list can be found at + this page. ui,standalone,historyServer,rpc @@ -732,7 +732,7 @@ Or via SparkConf "spark.hadoop.hadoop.security.credential.provider.path=jceks:// ## Preparing the key stores Key stores can be generated by `keytool` program. The reference documentation for this tool for -Java 17 is [here](https://docs.oracle.com/en/java/javase/17/docs/specs/man/keytool.html). +Java 21 is [here](https://docs.oracle.com/en/java/javase/21/docs/specs/man/keytool.html). The most basic steps to configure the key stores and the trust store for a Spark Standalone deployment mode is as follows: diff --git a/pom.xml b/pom.xml index 9c644ee81dc36..9b16ddf3fba96 100644 --- a/pom.xml +++ b/pom.xml @@ -121,8 +121,8 @@ UTF-8 UTF-8 - 17 - 17.0.11 + 21 + 21 ${java.version} 3.9.16 3.6.1 @@ -2836,7 +2836,7 @@ -feature -explaintypes -release - 17 + 21 -Wconf:any:e -Wconf:cat=deprecation:wv -Wunused:imports diff --git a/python/docs/source/getting_started/install.rst b/python/docs/source/getting_started/install.rst index 558ad51ac98f3..27309d6120e74 100644 --- a/python/docs/source/getting_started/install.rst +++ b/python/docs/source/getting_started/install.rst @@ -216,7 +216,7 @@ Additional libraries that enhance functionality but are not included in the inst - **memory-profiler**: Used for PySpark UDF memory profiling, ``spark.profile.show(...)`` and ``spark.sql.pyspark.udf.profiler``. - **plotly**: Used for PySpark plotting, ``DataFrame.plot``. -Note that PySpark requires Java 17 or later with ``JAVA_HOME`` properly set and refer to |downloading|_. +Note that PySpark requires Java 21 or later with ``JAVA_HOME`` properly set and refer to |downloading|_. .. _optional-dependencies: From 2c5dc65625494830782e88359b8944d95a2e6e44 Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Mon, 2 Nov 2026 15:31:42 -0800 Subject: [PATCH 2/3] Address comments --- .github/workflows/build_java17.yml | 29 ++++--------------- .github/workflows/build_maven_java21.yml | 16 ++++------ R/pkg/DESCRIPTION | 2 +- README.md | 1 - bin/pyspark | 8 ++--- dev/create-release/do-release-docker.sh | 2 +- dev/create-release/release-build.sh | 4 +++ dev/create-release/spark-rm/Dockerfile | 6 ++-- dev/create-release/spark-rm/Dockerfile.base | 2 +- docs/running-on-yarn.md | 10 +++---- docs/tuning.md | 10 +++---- .../dev/dev-run-integration-tests.sh | 2 +- 12 files changed, 36 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build_java17.yml b/.github/workflows/build_java17.yml index 9b365a2a5684a..5d0f5036c1265 100644 --- a/.github/workflows/build_java17.yml +++ b/.github/workflows/build_java17.yml @@ -23,28 +23,9 @@ on: workflow_dispatch: jobs: - run-build: - permissions: - packages: write - name: Run - uses: ./.github/workflows/build_and_test.yml + noop: if: github.repository == 'apache/spark' - with: - java: 17 - hadoop: hadoop3 - envs: >- - { - "SCALA_PROFILE": "scala2.13", - "PYSPARK_IMAGE_TO_TEST": "", - "PYTHON_TO_TEST": "" - } - jobs: >- - { - "build": "true", - "sparkr": "true", - "tpcds-1g": "true", - "docker-integration-tests": "true", - "k8s-integration-tests": "true", - "oidc-e2e": "true", - "lint" : "true" - } + runs-on: ubuntu-latest + steps: + - name: No-op + run: echo "Java 17 is not built on this branch. See branches that still support it (e.g. branch-4.x)." diff --git a/.github/workflows/build_maven_java21.yml b/.github/workflows/build_maven_java21.yml index ac03fc8f41673..202811df9c374 100644 --- a/.github/workflows/build_maven_java21.yml +++ b/.github/workflows/build_maven_java21.yml @@ -17,19 +17,15 @@ # under the License. # -name: "Build / Maven (Scala 2.13, JDK 21)" +name: "Build / Maven Java21 (Scala 2.13, JDK 21)" on: - schedule: - - cron: '0 14 */2 * *' workflow_dispatch: jobs: - run-build: - permissions: - packages: write - name: Run - uses: ./.github/workflows/maven_test.yml + noop: if: github.repository == 'apache/spark' - with: - java: 21 + runs-on: ubuntu-latest + steps: + - name: No-op + run: echo "Java 21 is the default on master and is not built separately. See branches that run it as a separate build (e.g. branch-4.x)." diff --git a/R/pkg/DESCRIPTION b/R/pkg/DESCRIPTION index a5c6876a4c932..4d16a785e0a7c 100644 --- a/R/pkg/DESCRIPTION +++ b/R/pkg/DESCRIPTION @@ -10,7 +10,7 @@ Authors@R: License: Apache License (== 2.0) URL: https://www.apache.org https://spark.apache.org BugReports: https://spark.apache.org/contributing.html -SystemRequirements: Java (>= 17, < 26) +SystemRequirements: Java (>= 21, < 26) Depends: R (>= 4.0), methods diff --git a/README.md b/README.md index 07fecf9b7777c..1b0207960bb75 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ This README file only contains basic setup instructions. | | [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_uds.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_uds.yml) | | | [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_rockdb_as_ui_backend.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_rockdb_as_ui_backend.yml) | | | [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_maven.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_maven.yml) | -| | [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_maven_java21.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_maven_java21.yml) | | | [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_maven_java25.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_maven_java25.yml) | | | [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_maven_java21_macos26.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_maven_java21_macos26.yml) | | | [![GitHub Actions Build](https://github.com/apache/spark/actions/workflows/build_maven_java21_arm.yml/badge.svg)](https://github.com/apache/spark/actions/workflows/build_maven_java21_arm.yml) | diff --git a/bin/pyspark b/bin/pyspark index 42edeac4ccb0f..f56b1f3cb5a7d 100755 --- a/bin/pyspark +++ b/bin/pyspark @@ -49,7 +49,7 @@ export PYSPARK_DRIVER_PYTHON export PYSPARK_DRIVER_PYTHON_OPTS # Attempt to find JAVA_HOME. -# If JAVA_HOME not set, install JDK 17 and set JAVA_HOME using a temp dir, and adding the +# If JAVA_HOME not set, install JDK 21 and set JAVA_HOME using a temp dir, and adding the # temp dir to the PYTHONPATH. if [ -n "${JAVA_HOME}" ]; then RUNNER="${JAVA_HOME}/bin/java" @@ -57,19 +57,19 @@ else if [ "$(command -v java)" ]; then RUNNER="java" else - echo -n "JAVA_HOME is not set. Would you like to install JDK 17 and set JAVA_HOME? (Y/N) " >&2 + echo -n "JAVA_HOME is not set. Would you like to install JDK 21 and set JAVA_HOME? (Y/N) " >&2 read -r input if [[ "${input,,}" == "y" ]]; then TEMP_DIR=$(mktemp -d) $PYSPARK_DRIVER_PYTHON -m pip install --target="$TEMP_DIR" install-jdk - export JAVA_HOME=$(PYTHONPATH="$TEMP_DIR" $PYSPARK_DRIVER_PYTHON -c 'import jdk; print(jdk.install("17"))') + export JAVA_HOME=$(PYTHONPATH="$TEMP_DIR" $PYSPARK_DRIVER_PYTHON -c 'import jdk; print(jdk.install("21"))') RUNNER="${JAVA_HOME}/bin/java" echo "JDK was installed to the path \"$JAVA_HOME\"" echo "You can avoid needing to re-install JDK by setting your JAVA_HOME environment variable to \"$JAVA_HOME\"" else - echo "JDK installation skipped. You can manually install JDK (17 or later) and set JAVA_HOME in your environment." + echo "JDK installation skipped. You can manually install JDK (21 or later) and set JAVA_HOME in your environment." exit 1 fi fi diff --git a/dev/create-release/do-release-docker.sh b/dev/create-release/do-release-docker.sh index d0b4ada85659f..c2ac77864301c 100755 --- a/dev/create-release/do-release-docker.sh +++ b/dev/create-release/do-release-docker.sh @@ -45,7 +45,7 @@ Options are: -n : dry run mode. Performs checks and local builds, but do not upload anything. -t [tag] : tag for the spark-rm docker image to use for building (default: "latest"). -j [path] : path to local JDK installation to use for building. By default the script will - use openjdk17 installed in the docker image. + use openjdk21 installed in the docker image. -s [step] : runs a single step of the process; valid steps are: tag, build, docs, publish, finalize EOF } diff --git a/dev/create-release/release-build.sh b/dev/create-release/release-build.sh index 36ec915a134e0..1ae2b0136ca73 100755 --- a/dev/create-release/release-build.sh +++ b/dev/create-release/release-build.sh @@ -693,6 +693,10 @@ elif [[ $JAVA_VERSION < "17.0." ]] && [[ $SPARK_VERSION > "3.5.99" ]]; then echo "Java version $JAVA_VERSION is less than required 17 for 4.0+" echo "Please set JAVA_HOME correctly." exit 1 +elif [[ $JAVA_VERSION < "21" ]] && [[ $SPARK_VERSION > "4.99" ]]; then + echo "Java version $JAVA_VERSION is less than required 21 for 5.0+" + echo "Please set JAVA_HOME correctly." + exit 1 fi if [ -z "$SPARK_PACKAGE_VERSION" ]; then diff --git a/dev/create-release/spark-rm/Dockerfile b/dev/create-release/spark-rm/Dockerfile index 20d8f847e1b25..e0a3a0c63a2a1 100644 --- a/dev/create-release/spark-rm/Dockerfile +++ b/dev/create-release/spark-rm/Dockerfile @@ -17,14 +17,14 @@ # Spark master (5.0.0-SNAPSHOT) release image # Extends the base image with: -# - Java 17 +# - Java 21 # - Python 3.11 with required packages FROM spark-rm-base:latest -# Install Java 17 for Spark 5.x +# Install Java 21 for Spark 5.x RUN apt-get update && apt-get install -y \ - openjdk-17-jdk-headless \ + openjdk-21-jdk-headless \ && rm -rf /var/lib/apt/lists/* # Install Python 3.11 diff --git a/dev/create-release/spark-rm/Dockerfile.base b/dev/create-release/spark-rm/Dockerfile.base index b7a2da7729bdd..97de0e3148842 100644 --- a/dev/create-release/spark-rm/Dockerfile.base +++ b/dev/create-release/spark-rm/Dockerfile.base @@ -24,7 +24,7 @@ # - Node.js for documentation # # Branch-specific Dockerfiles should use "FROM spark-rm-base:latest" and add: -# - Java version (8 or 17) +# - Java version (8, 17, or 21) # - Python version and pip packages FROM ubuntu:jammy-20250819 diff --git a/docs/running-on-yarn.md b/docs/running-on-yarn.md index fa689c1e18f1b..2086e2e799b98 100644 --- a/docs/running-on-yarn.md +++ b/docs/running-on-yarn.md @@ -33,7 +33,7 @@ Please see [Spark Security](security.html) and the specific security sections in # Launching Spark on YARN -Apache Hadoop supports Java 17 since 3.5.0, while Apache Spark requires at least Java 17 since 4.0.0. When running on a YARN cluster whose Hadoop version is older than 3.5.0, a different JDK should be configured for Spark applications. +Apache Spark requires at least Java 21 since 5.0.0. When running on a YARN cluster with a Java version older than 21, a different JDK should be configured for Spark applications. Please refer to [Configuring different JDKs for Spark Applications](#configuring-different-jdks-for-spark-applications) for details. Ensure that `HADOOP_CONF_DIR` or `YARN_CONF_DIR` points to the directory which contains the (client side) configuration files for the Hadoop cluster. @@ -1069,13 +1069,13 @@ process. Note that, Spark assumes that all JVM processes runs in one application use the same version of JDK, otherwise, you may encounter JDK serialization issues. -To configure a Spark application to use a JDK which has been pre-installed on all nodes at `/opt/openjdk-17`: +To configure a Spark application to use a JDK which has been pre-installed on all nodes at `/opt/openjdk-21`: - $ export JAVA_HOME=/opt/openjdk-17 + $ export JAVA_HOME=/opt/openjdk-21 $ ./bin/spark-submit --class path.to.your.Class \ --master yarn \ - --conf spark.yarn.appMasterEnv.JAVA_HOME=/opt/openjdk-17 \ - --conf spark.executorEnv.JAVA_HOME=/opt/openjdk-17 \ + --conf spark.yarn.appMasterEnv.JAVA_HOME=/opt/openjdk-21 \ + --conf spark.executorEnv.JAVA_HOME=/opt/openjdk-21 \ [app options] Optionally, the user may want to avoid installing a different JDK on the YARN cluster nodes, in such a case, diff --git a/docs/tuning.md b/docs/tuning.md index f72dc0efd98eb..fce00286e914c 100644 --- a/docs/tuning.md +++ b/docs/tuning.md @@ -41,12 +41,12 @@ Often, this will be the first thing you should tune to optimize a Spark applicat Spark aims to strike a balance between convenience (allowing you to work with any Java type in your operations) and performance. It provides two serialization libraries: -* [Java serialization](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Serializable.html): +* [Java serialization](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/Serializable.html): By default, Spark serializes objects using Java's `ObjectOutputStream` framework, and can work with any class you create that implements - [`java.io.Serializable`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Serializable.html). + [`java.io.Serializable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/Serializable.html). You can also control the performance of your serialization more closely by extending - [`java.io.Externalizable`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Externalizable.html). + [`java.io.Externalizable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/Externalizable.html). Java serialization is flexible but often quite slow, and leads to large serialized formats for many classes. * [Kryo serialization](https://github.com/EsotericSoftware/kryo): Spark can also use @@ -232,7 +232,7 @@ temporary objects created during task execution. Some steps which may be useful value of the JVM's `NewRatio` parameter. Many JVMs default this to 2, meaning that the Old generation occupies 2/3 of the heap. It should be large enough such that this fraction exceeds `spark.memory.fraction`. -* Since 4.0.0, Spark uses JDK 17 by default, which also makes the G1GC garbage collector the default. Note that with +* Since 5.0.0, Spark uses JDK 21 by default, which also makes the G1GC garbage collector the default. Note that with large executor heap sizes, it may be important to increase the G1 region size with `-XX:G1HeapRegionSize`. * As an example, if your task is reading data from HDFS, the amount of memory used by the task can be estimated using @@ -243,7 +243,7 @@ temporary objects created during task execution. Some steps which may be useful * Monitor how the frequency and time taken by garbage collection changes with the new settings. Our experience suggests that the effect of GC tuning depends on your application and the amount of memory available. -There are [many more tuning options](https://docs.oracle.com/en/java/javase/17/gctuning/introduction-garbage-collection-tuning.html) described online, +There are [many more tuning options](https://docs.oracle.com/en/java/javase/21/gctuning/introduction-garbage-collection-tuning.html) described online, but at a high level, managing how frequently full GC takes place can help in reducing the overhead. GC tuning flags for executors can be specified by setting `spark.executor.defaultJavaOptions` or `spark.executor.extraJavaOptions` in diff --git a/resource-managers/kubernetes/integration-tests/dev/dev-run-integration-tests.sh b/resource-managers/kubernetes/integration-tests/dev/dev-run-integration-tests.sh index a0834e1ff23f4..34c9f9e0ce761 100755 --- a/resource-managers/kubernetes/integration-tests/dev/dev-run-integration-tests.sh +++ b/resource-managers/kubernetes/integration-tests/dev/dev-run-integration-tests.sh @@ -38,7 +38,7 @@ CONTEXT= INCLUDE_TAGS="k8s" EXCLUDE_TAGS= DEFAULT_EXCLUDE_TAGS="N/A" -JAVA_VERSION="17" +JAVA_VERSION="21" BUILD_DEPENDENCIES_MVN_FLAG="-am" HADOOP_PROFILE="hadoop-3" MVN="$TEST_ROOT_DIR/build/mvn" From 6d58bc2e4ec8a502dc03f37db7e5ca3a32910233 Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Mon, 2 Nov 2026 19:57:11 -0800 Subject: [PATCH 3/3] Address comments --- .github/workflows/build_and_test.yml | 2 +- .github/workflows/build_java17.yml | 8 ++++++++ .github/workflows/build_maven_java21.yml | 9 +++++++++ dev/create-release/release-build.sh | 8 ++++---- docs/tuning.md | 2 +- resource-managers/kubernetes/integration-tests/README.md | 2 +- .../sql/execution/datasources/v2/ffi/NativeLibrary.java | 2 +- 7 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 234f38f48da6d..cff932a8fc30e 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -953,7 +953,7 @@ jobs: export MAVEN_CLI_OPTS="--no-transfer-progress" ./build/mvn $MAVEN_CLI_OPTS -DskipTests -Pyarn -Pkubernetes -Pvolcano -Phive -Phive-thriftserver -Phadoop-cloud -Pjvm-profiler -Pspark-ganglia-lgpl -Pkinesis-asl -Pcredential-aws clean install # Native data sources are called with the FFM API, which requires Java 22 or later, so the - # other jobs, on Java 17, skip the tests that load a library. The tests build their library + # other jobs, on Java 21, skip the tests that load a library. The tests build their library # with the C++ compiler of the runner. - name: Test native data sources run: | diff --git a/.github/workflows/build_java17.yml b/.github/workflows/build_java17.yml index 5d0f5036c1265..e0387cb994c72 100644 --- a/.github/workflows/build_java17.yml +++ b/.github/workflows/build_java17.yml @@ -17,6 +17,14 @@ # under the License. # +# This is a placeholder. Java 17 is not supported on master since Spark 5.0, so +# master does not run this build. The file exists here only so that the README +# build status badge, which resolves a workflow by its path on the default +# branch, renders for the branches that still run it (e.g. branch-4.x), and so +# that branch4*_scheduler.yml can dispatch it to those branches with +# `gh workflow run --ref`. The actual build is defined in the same file on +# those branches. + name: "Build / Java17 (Scala 2.13, JDK 17)" on: diff --git a/.github/workflows/build_maven_java21.yml b/.github/workflows/build_maven_java21.yml index 202811df9c374..b69b878f0b924 100644 --- a/.github/workflows/build_maven_java21.yml +++ b/.github/workflows/build_maven_java21.yml @@ -17,6 +17,15 @@ # under the License. # +# This is a placeholder. Java 21 is the default on master, so build_maven.yml +# already runs the Maven build with Java 21 and there is no separate scheduled +# build here. The file exists only so that the README build status badge, which +# resolves a workflow by its path on the default branch, renders for the +# branches that still run it as a separate build (e.g. branch-4.x), and so that +# branch4*_scheduler.yml can dispatch it to those branches with +# `gh workflow run --ref`. The actual build is defined in the same file on +# those branches. + name: "Build / Maven Java21 (Scala 2.13, JDK 21)" on: diff --git a/dev/create-release/release-build.sh b/dev/create-release/release-build.sh index 1ae2b0136ca73..0067541833430 100755 --- a/dev/create-release/release-build.sh +++ b/dev/create-release/release-build.sh @@ -689,14 +689,14 @@ if [[ $JAVA_VERSION < "1.8." ]] && [[ $SPARK_VERSION < "4.0" ]]; then echo "Java version $JAVA_VERSION is less than required 1.8 for 2.2+" echo "Please set JAVA_HOME correctly." exit 1 -elif [[ $JAVA_VERSION < "17.0." ]] && [[ $SPARK_VERSION > "3.5.99" ]]; then - echo "Java version $JAVA_VERSION is less than required 17 for 4.0+" - echo "Please set JAVA_HOME correctly." - exit 1 elif [[ $JAVA_VERSION < "21" ]] && [[ $SPARK_VERSION > "4.99" ]]; then echo "Java version $JAVA_VERSION is less than required 21 for 5.0+" echo "Please set JAVA_HOME correctly." exit 1 +elif [[ $JAVA_VERSION < "17.0." ]] && [[ $SPARK_VERSION > "3.5.99" ]]; then + echo "Java version $JAVA_VERSION is less than required 17 for 4.0+" + echo "Please set JAVA_HOME correctly." + exit 1 fi if [ -z "$SPARK_PACKAGE_VERSION" ]; then diff --git a/docs/tuning.md b/docs/tuning.md index fce00286e914c..e07463f204b86 100644 --- a/docs/tuning.md +++ b/docs/tuning.md @@ -232,7 +232,7 @@ temporary objects created during task execution. Some steps which may be useful value of the JVM's `NewRatio` parameter. Many JVMs default this to 2, meaning that the Old generation occupies 2/3 of the heap. It should be large enough such that this fraction exceeds `spark.memory.fraction`. -* Since 5.0.0, Spark uses JDK 21 by default, which also makes the G1GC garbage collector the default. Note that with +* Spark requires JDK 21 or later, where G1GC is the default garbage collector. Note that with large executor heap sizes, it may be important to increase the G1 region size with `-XX:G1HeapRegionSize`. * As an example, if your task is reading data from HDFS, the amount of memory used by the task can be estimated using diff --git a/resource-managers/kubernetes/integration-tests/README.md b/resource-managers/kubernetes/integration-tests/README.md index f1373a26f05c5..11a8c829feecb 100644 --- a/resource-managers/kubernetes/integration-tests/README.md +++ b/resource-managers/kubernetes/integration-tests/README.md @@ -142,7 +142,7 @@ The tests are tagged, and the set of tests to run can be controlled via the foll ## Customising the Build -* `--java-version ` - Java version to build Spark and the tests with. The default is `17`. +* `--java-version ` - Java version to build Spark and the tests with. The default is `21`. * `--hadoop-profile ` - Hadoop Maven profile to build with. The default is `hadoop-3`. * `--skip-building-dependencies` - skip rebuilding the modules the integration tests depend on (drops Maven's `-am` flag). Useful for iterating when the current tree is already built. diff --git a/sql/core/src/main/java/org/apache/spark/sql/execution/datasources/v2/ffi/NativeLibrary.java b/sql/core/src/main/java/org/apache/spark/sql/execution/datasources/v2/ffi/NativeLibrary.java index d1eb63b2a942e..624d5ed9fc72f 100644 --- a/sql/core/src/main/java/org/apache/spark/sql/execution/datasources/v2/ffi/NativeLibrary.java +++ b/sql/core/src/main/java/org/apache/spark/sql/execution/datasources/v2/ffi/NativeLibrary.java @@ -43,7 +43,7 @@ * {@code org/apache/spark/sql/datasource/spark_datasource.h}, called through the Foreign Function * and Memory (FFM) API of Java 22 and later. *

- * Spark compiles for Java 17, where the FFM API does not exist, so the API is only reached + * Spark compiles for Java 21, where the FFM API is still in preview, so the API is only reached * through method handles, looked up once when the first library is loaded. The library exports * {@code spark_ds_init}, which returns its table of functions, {@code SparkDsLibrary}. Each * function of the table is bound to a method handle that takes and returns primitive values only,