From 25fcc8d5236327d67ad611b49b855cc9e8c6cfa7 Mon Sep 17 00:00:00 2001 From: Yi Hu Date: Wed, 22 Apr 2026 18:08:54 -0400 Subject: [PATCH] Bump Java bytecode compatibility version to Java11 --- ...PostCommit_Java_Examples_Dataflow_Java.yml | 2 +- ...tCommit_Java_Examples_Dataflow_V2_Java.yml | 2 +- .../beam_PostCommit_Java_Hadoop_Versions.yml | 12 -- ...ommit_Java_ValidatesRunner_Flink_Java8.yml | 102 -------------- ...ommit_Java_ValidatesRunner_Spark_Java8.yml | 102 -------------- .../workflows/beam_PreCommit_SQL_Java8.yml | 129 ------------------ CHANGES.md | 1 + .../beam/gradle/BeamModulePlugin.groovy | 9 +- gradle.properties | 2 +- ...reamingEngineComputationConfigFetcher.java | 2 +- .../beam/sdk/io/synthetic/SyntheticStep.java | 2 + .../content/en/documentation/sdks/java.md | 2 +- 12 files changed, 15 insertions(+), 352 deletions(-) delete mode 100644 .github/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml delete mode 100644 .github/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml delete mode 100644 .github/workflows/beam_PreCommit_SQL_Java8.yml diff --git a/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_Java.yml b/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_Java.yml index 007ca1a600c0..f38bd7ae5c1b 100644 --- a/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_Java.yml +++ b/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_Java.yml @@ -60,7 +60,7 @@ jobs: matrix: job_name: [beam_PostCommit_Java_Examples_Dataflow_Java] job_phrase: [Run Java examples on Dataflow Java] - java_version: ['8','17','21', '25'] + java_version: ['17', '21', '25'] if: | github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request_target' || diff --git a/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_V2_Java.yml b/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_V2_Java.yml index 373e49524a65..72d59d89f8f3 100644 --- a/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_V2_Java.yml +++ b/.github/workflows/beam_PostCommit_Java_Examples_Dataflow_V2_Java.yml @@ -61,7 +61,7 @@ jobs: job_name: [beam_PostCommit_Java_Examples_Dataflow_V2_Java] job_phrase_1: [Run Java ] job_phrase_2: [Examples on Dataflow Runner V2] - java_version: ['8', '17', '21', '25'] + java_version: ['17', '21', '25'] if: | github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request_target' || diff --git a/.github/workflows/beam_PostCommit_Java_Hadoop_Versions.yml b/.github/workflows/beam_PostCommit_Java_Hadoop_Versions.yml index 8c0d35e87f07..e0c26b293169 100644 --- a/.github/workflows/beam_PostCommit_Java_Hadoop_Versions.yml +++ b/.github/workflows/beam_PostCommit_Java_Hadoop_Versions.yml @@ -72,22 +72,10 @@ jobs: github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) - name: Setup environment uses: ./.github/actions/setup-environment-action - with: - java-version: | - 8 - 11 - name: run javaHadoopVersionsTest script uses: ./.github/actions/gradle-command-self-hosted-action with: gradle-command: :javaHadoopVersionsTest - # TODO(https://github.com/apache/beam/issues/32189) remove when embedded hive supports Java11 - - name: run java8HadoopVersionsTest script - uses: ./.github/actions/gradle-command-self-hosted-action - with: - gradle-command: :sdks:java:io:hcatalog:hadoopVersionsTest - arguments: | - -PtestJavaVersion=8 \ - -Pjava8Home=$JAVA_HOME_8_X64 \ - name: Archive JUnit Test Results uses: actions/upload-artifact@v4 if: ${{ !success() }} diff --git a/.github/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml b/.github/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml deleted file mode 100644 index ac4093a361c4..000000000000 --- a/.github/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml +++ /dev/null @@ -1,102 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# 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. - -name: PostCommit Java ValidatesRunner Flink Java8 - -on: - schedule: - - cron: '45 5/6 * * *' - pull_request_target: - paths: ['release/trigger_all_tests.json', '.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.json'] - workflow_dispatch: - -# This allows a subsequently queued workflow run to interrupt previous runs -concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.number || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}' - cancel-in-progress: true - -#Setting explicit permissions for the action to avoid the default permissions which are `write-all` in case of pull_request_target event -permissions: - actions: write - pull-requests: write - checks: write - contents: read - deployments: read - id-token: none - issues: write - discussions: read - packages: read - pages: read - repository-projects: read - security-events: read - statuses: read - -env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} - GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }} - GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }} - -jobs: - beam_PostCommit_Java_ValidatesRunner_Flink_Java8: - name: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) - runs-on: [self-hosted, ubuntu-24.04, main] - timeout-minutes: 270 - strategy: - matrix: - job_name: [beam_PostCommit_Java_ValidatesRunner_Flink_Java8] - job_phrase: [Run Flink ValidatesRunner Java 8] - if: | - github.event_name == 'workflow_dispatch' || - github.event_name == 'pull_request_target' || - (github.event_name == 'schedule' && github.repository == 'apache/beam') || - startswith(github.event.comment.body, 'Run Flink ValidatesRunner Java 8') - steps: - - uses: actions/checkout@v4 - - name: Setup repository - uses: ./.github/actions/setup-action - with: - comment_phrase: ${{ matrix.job_phrase }} - github_token: ${{ secrets.GITHUB_TOKEN }} - github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) - - name: Setup environment - uses: ./.github/actions/setup-environment-action - with: - java-version: | - 8 - 11 - - name: run validatesRunner Java8 script - uses: ./.github/actions/gradle-command-self-hosted-action - with: - gradle-command: :runners:flink:1.20:validatesRunner - arguments: | - -PtestJavaVersion=8 \ - -Pjava8Home=$JAVA_HOME_8_X64 \ - max-workers: 12 - - name: Archive JUnit Test Results - uses: actions/upload-artifact@v4 - if: ${{ !success() }} - with: - name: JUnit Test Results - path: "**/build/reports/tests/" - - name: Publish JUnit Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - large_files: true - commit: '${{ env.prsha || env.GITHUB_SHA }}' - comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }} - files: '**/build/test-results/**/*.xml' diff --git a/.github/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml b/.github/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml deleted file mode 100644 index fab48ec60019..000000000000 --- a/.github/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml +++ /dev/null @@ -1,102 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# 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. - -name: PostCommit Java ValidatesRunner Spark Java8 - -on: - schedule: - - cron: '45 4/6 * * *' - pull_request_target: - paths: ['release/trigger_all_tests.json', '.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.json'] - workflow_dispatch: - -# This allows a subsequently queued workflow run to interrupt previous runs -concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.number || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}' - cancel-in-progress: true - -#Setting explicit permissions for the action to avoid the default permissions which are `write-all` in case of pull_request_target event -permissions: - actions: write - pull-requests: write - checks: write - contents: read - deployments: read - id-token: none - issues: write - discussions: read - packages: read - pages: read - repository-projects: read - security-events: read - statuses: read - -env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} - GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }} - GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }} - -jobs: - beam_PostCommit_Java_ValidatesRunner_Spark_Java8: - name: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) - runs-on: [self-hosted, ubuntu-24.04, main] - timeout-minutes: 270 - strategy: - matrix: - job_name: [beam_PostCommit_Java_ValidatesRunner_Spark_Java8] - job_phrase: [Run Spark ValidatesRunner Java 8] - if: | - github.event_name == 'workflow_dispatch' || - github.event_name == 'pull_request_target' || - (github.event_name == 'schedule' && github.repository == 'apache/beam') || - startswith(github.event.comment.body, 'Run Spark ValidatesRunner Java 8') - steps: - - uses: actions/checkout@v4 - - name: Setup repository - uses: ./.github/actions/setup-action - with: - comment_phrase: ${{ matrix.job_phrase }} - github_token: ${{ secrets.GITHUB_TOKEN }} - github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) - - name: Setup environment - uses: ./.github/actions/setup-environment-action - with: - java-version: | - 8 - 11 - - name: run validatesRunner Java8 script - uses: ./.github/actions/gradle-command-self-hosted-action - with: - gradle-command: :runners:spark:3:validatesRunner - arguments: | - -PtestJavaVersion=8 \ - -Pjava8Home=$JAVA_HOME_8_X64 \ - max-workers: 12 - - name: Archive JUnit Test Results - uses: actions/upload-artifact@v4 - if: ${{ !success() }} - with: - name: JUnit Test Results - path: "**/build/reports/tests/" - - name: Publish JUnit Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - commit: '${{ env.prsha || env.GITHUB_SHA }}' - comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }} - files: '**/build/test-results/**/*.xml' - large_files: true \ No newline at end of file diff --git a/.github/workflows/beam_PreCommit_SQL_Java8.yml b/.github/workflows/beam_PreCommit_SQL_Java8.yml deleted file mode 100644 index 1e69b3e3ca4c..000000000000 --- a/.github/workflows/beam_PreCommit_SQL_Java8.yml +++ /dev/null @@ -1,129 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one 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. - -name: PreCommit SQL Java8 - -on: - push: - tags: ['v*'] - branches: ['master', 'release-*'] - paths: ['sdks/java/extensions/sql/**','.github/workflows/beam_PreCommit_SQL_Java8.yml'] - pull_request_target: - branches: ['master', 'release-*'] - paths: ['sdks/java/extensions/sql/**', 'release/trigger_all_tests.json', '.github/trigger_files/beam_PreCommit_SQL_Java8.json'] - issue_comment: - types: [created] - schedule: - - cron: '15 3/6 * * *' - workflow_dispatch: - -# This allows a subsequently queued workflow run to interrupt previous runs -concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.number || github.event.pull_request.head.label || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}' - cancel-in-progress: true - -env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} - GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }} - GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }} - -# Setting explicit permissions for the action to avoid the default permissions which are `write-all` in case of pull_request_target event -permissions: - actions: write - pull-requests: write - checks: write - contents: read - deployments: read - id-token: none - issues: write - discussions: read - packages: read - pages: read - repository-projects: read - security-events: read - statuses: read - -jobs: - beam_PreCommit_SQL_Java8: - name: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) - runs-on: [self-hosted, ubuntu-24.04, main] - strategy: - matrix: - job_name: [beam_PreCommit_SQL_Java8] - job_phrase: [Run SQL_Java8 PreCommit] - timeout-minutes: 120 - if: | - github.event_name == 'push' || - github.event_name == 'pull_request_target' || - (github.event_name == 'schedule' && github.repository == 'apache/beam') || - github.event_name == 'workflow_dispatch' || - github.event.comment.body == 'Run SQL_Java8 PreCommit' - steps: - - uses: actions/checkout@v4 - - name: Setup repository - uses: ./.github/actions/setup-action - with: - comment_phrase: ${{ matrix.job_phrase }} - github_token: ${{ secrets.GITHUB_TOKEN }} - github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) - - name: Setup environment - uses: ./.github/actions/setup-environment-action - with: - java-version: | - 8 - 11 - python-version: default - go-version: default - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.10.4' - channel: 'stable' - - name: Build and Test - uses: ./.github/actions/gradle-command-self-hosted-action - with: - gradle-command: :sdks:java:extensions:sql:preCommit - arguments: | - -PdisableSpotlessCheck=true \ - -PdisableCheckStyle=true \ - -PtestJavaVersion=8 \ - -PskipCheckerFramework \ - -Pjava8Home=$JAVA_HOME_8_X64 \ - - name: Archive JUnit Test Results - uses: actions/upload-artifact@v4 - if: ${{ !success() }} - with: - name: JUnit Test Results - path: "**/build/reports/tests/" - - name: Publish JUnit Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - commit: '${{ env.prsha || env.GITHUB_SHA }}' - comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }} - files: '**/build/test-results/**/*.xml' - large_files: true - - name: Archive SpotBugs Results - uses: actions/upload-artifact@v4 - if: always() - with: - name: SpotBugs Results - path: '**/build/reports/spotbugs/*.html' - - name: Publish SpotBugs Results - uses: jwgmeligmeyling/spotbugs-github-action@v1.2 - if: always() - with: - name: Publish SpotBugs - path: '**/build/reports/spotbugs/*.html' \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md index bdcbd3451c7b..6f487ce7ff8f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -82,6 +82,7 @@ ## Deprecations * X behavior is deprecated and will be removed in X versions ([#X](https://github.com/apache/beam/issues/X)). +* Dropped Java 8 support ([#31678](https://github.com/apache/beam/issues/31678)). ## Bugfixes diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy index 2730891bf861..cd8ba2c8a265 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -1132,6 +1132,8 @@ class BeamModulePlugin implements Plugin { project.javaVersion = '17' } else if (JavaVersion.VERSION_21.equals(configuration.requireJavaVersion)) { project.javaVersion = '21' + } else if (JavaVersion.VERSION_25.equals(configuration.requireJavaVersion)) { + project.javaVersion = '25' } else { throw new GradleException( "requireJavaVersion has to be supported LTS version greater than the default Java version. Actual: " + @@ -1154,6 +1156,9 @@ class BeamModulePlugin implements Plugin { } else if (requireJavaVersion.compareTo(JavaVersion.VERSION_21) <= 0 && project.hasProperty('java21Home')) { forkJavaVersion = '21' + } else if (requireJavaVersion.compareTo(JavaVersion.VERSION_25) <= 0 && + project.hasProperty('java25Home')) { + forkJavaVersion = '25' } else { logger.config("Module ${project.name} disabled. To enable, either " + "compile on newer Java version or pass java${project.javaVersion}Home project property") @@ -1582,7 +1587,7 @@ class BeamModulePlugin implements Plugin { options.encoding = "UTF-8" // If compiled on newer JDK, set byte code compatibility if (requireJavaVersion.compareTo(JavaVersion.current()) < 0) { - def compatVersion = project.javaVersion == '1.8' ? '8' : project.javaVersion + def compatVersion = project.javaVersion == '11' ? '11' : project.javaVersion options.compilerArgs += ['--release', compatVersion] // TODO(https://github.com/apache/beam/issues/23901): Fix // optimizerOuterThis breakage @@ -1616,7 +1621,7 @@ class BeamModulePlugin implements Plugin { } // if specified test java version, modify the compile and runtime versions accordingly - if (['8', '11', '17', '21', '25'].contains(project.findProperty('testJavaVersion'))) { + if (['11', '17', '21', '25'].contains(project.findProperty('testJavaVersion'))) { String ver = project.getProperty('testJavaVersion') def testJavaHome = project.getProperty("java${ver}Home") diff --git a/gradle.properties b/gradle.properties index 2cff0b656fa7..583eb24d8964 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,7 +33,7 @@ signing.gnupg.useLegacyGpg=true version=2.74.0-SNAPSHOT sdk_version=2.74.0.dev -javaVersion=1.8 +javaVersion=11 docker_image_default_repo_root=apache docker_image_default_repo_prefix=beam_ diff --git a/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/config/StreamingEngineComputationConfigFetcher.java b/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/config/StreamingEngineComputationConfigFetcher.java index 6ade84403713..08263bd2243a 100644 --- a/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/config/StreamingEngineComputationConfigFetcher.java +++ b/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/config/StreamingEngineComputationConfigFetcher.java @@ -171,7 +171,7 @@ private StreamingGlobalConfig createPipelineConfig(StreamingConfigTask config) { ImmutableSet endpoints = StreamSupport.stream( Splitter.on(',').split(config.getWindmillServiceEndpoint()).spliterator(), - /* isParallel= */ false) + /* parallel= */ false) .map(endpoint -> HostAndPort.fromString(endpoint).withDefaultPort(windmillPort)) .collect(toImmutableSet()); diff --git a/sdks/java/io/synthetic/src/main/java/org/apache/beam/sdk/io/synthetic/SyntheticStep.java b/sdks/java/io/synthetic/src/main/java/org/apache/beam/sdk/io/synthetic/SyntheticStep.java index 78e0d4ff5f3a..1e0de64bc091 100644 --- a/sdks/java/io/synthetic/src/main/java/org/apache/beam/sdk/io/synthetic/SyntheticStep.java +++ b/sdks/java/io/synthetic/src/main/java/org/apache/beam/sdk/io/synthetic/SyntheticStep.java @@ -21,6 +21,7 @@ import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument; import com.fasterxml.jackson.annotation.JsonProperty; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Random; import java.util.concurrent.TimeUnit; import org.apache.beam.sdk.io.synthetic.delay.SyntheticDelay; @@ -83,6 +84,7 @@ public SyntheticStep(Options options) { } @ProcessElement + @SuppressFBWarnings("DMI_RANDOM_USED_ONLY_ONCE") // intended public void processElement(ProcessContext c) throws Exception { byte[] key = c.element().getKey(); byte[] val = c.element().getValue(); diff --git a/website/www/site/content/en/documentation/sdks/java.md b/website/www/site/content/en/documentation/sdks/java.md index 971d9951197f..659e1078ed89 100644 --- a/website/www/site/content/en/documentation/sdks/java.md +++ b/website/www/site/content/en/documentation/sdks/java.md @@ -78,6 +78,6 @@ Apache Beam lets you combine transforms written in any supported SDK language an 8 - 2.x + ≤ 2.73.0 \ No newline at end of file