From 895a51f60b9752f52c8d9c041e03f0fef69d4769 Mon Sep 17 00:00:00 2001 From: Shunping Huang Date: Thu, 15 Oct 2026 15:24:33 -0400 Subject: [PATCH 1/3] Partially revert #40595 to fix compilation error. --- .../beam/gradle/BeamModulePlugin.groovy | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) 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 6550dbd843b4..409f159fa8c7 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -482,19 +482,37 @@ class BeamModulePlugin implements Plugin { /* * Set compile args for compiling and running in different java version by modifying the compiler args in place. * - * Replace `--release X` option if already existed in compilerArgs. + * Replace `-source X` and `-target X` or `--release X` options if already existed in compilerArgs. + * + * Note: `--release X` is intentionally replaced with `-source X -target X`. When javac is forked with a + * different javaHome, Error Prone's `--add-exports=jdk.compiler/...` flags end up passed to javac as compiler + * args, and javac rejects exporting packages from system modules when `--release` is set + * (see https://github.com/apache/beam/pull/28291). */ static def setCompileAndRuntimeJavaVersion(List compilerArgs, String ver) { - boolean foundR = false + boolean foundS = false, foundT = false + int foundR = -1 logger.fine("set java ver ${ver} to compiler args") for (int i = 0; i < compilerArgs.size() - 1; ++i) { - if (compilerArgs.get(i) == '--release') { - foundR = true + if (compilerArgs.get(i) == '-source') { + foundS = true + compilerArgs.set(i + 1, ver) + } else if (compilerArgs.get(i) == '-target') { + foundT = true compilerArgs.set(i + 1, ver) + } else if (compilerArgs.get(i) == '--release') { + foundR = i } } - if (!foundR) { - compilerArgs.addAll('--release', ver) + if (foundR != -1) { + compilerArgs.removeAt(foundR + 1) + compilerArgs.removeAt(foundR) + } + if (!foundS) { + compilerArgs.addAll('-source', ver) + } + if (!foundT) { + compilerArgs.addAll('-target', ver) } } From d7a06e1c4e6c3915caf9f1272744092c680c2600 Mon Sep 17 00:00:00 2001 From: Shunping Huang Date: Thu, 15 Oct 2026 15:27:06 -0400 Subject: [PATCH 2/3] Trigger test workflow --- .github/trigger_files/beam_PreCommit_Java_IOs_Direct.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/trigger_files/beam_PreCommit_Java_IOs_Direct.json diff --git a/.github/trigger_files/beam_PreCommit_Java_IOs_Direct.json b/.github/trigger_files/beam_PreCommit_Java_IOs_Direct.json new file mode 100644 index 000000000000..5abe02fc09c7 --- /dev/null +++ b/.github/trigger_files/beam_PreCommit_Java_IOs_Direct.json @@ -0,0 +1,4 @@ +{ + "comment": "Modify this file in a trivial way to cause this test suite to run.", + "modification": 1 +} From 084556c0d21e3a050922c1787dda53befcb1fb5d Mon Sep 17 00:00:00 2001 From: Shunping Huang Date: Thu, 15 Oct 2026 15:29:17 -0400 Subject: [PATCH 3/3] Remove uncessary comments --- .../groovy/org/apache/beam/gradle/BeamModulePlugin.groovy | 5 ----- 1 file changed, 5 deletions(-) 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 409f159fa8c7..fd67d8f955d6 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -483,11 +483,6 @@ class BeamModulePlugin implements Plugin { * Set compile args for compiling and running in different java version by modifying the compiler args in place. * * Replace `-source X` and `-target X` or `--release X` options if already existed in compilerArgs. - * - * Note: `--release X` is intentionally replaced with `-source X -target X`. When javac is forked with a - * different javaHome, Error Prone's `--add-exports=jdk.compiler/...` flags end up passed to javac as compiler - * args, and javac rejects exporting packages from system modules when `--release` is set - * (see https://github.com/apache/beam/pull/28291). */ static def setCompileAndRuntimeJavaVersion(List compilerArgs, String ver) { boolean foundS = false, foundT = false