Skip to content

Commit 94355b1

Browse files
fmeumcopybara-github
authored andcommitted
Add required --add-opens server JVM args also with non-embedded JDK
Since the Bazel server requires JDK 11 or higher to run, the `--add-opens` server JVM arg for `java.lang` can now be added unconditionally, which ensures support with JDK 17+. Also removes the additional opens for `java.nio`, which was only needed to silence a protobuf warning that has since been fixed upstream. Fixes bazelbuild#16705 Fixes bazelbuild#15831 Closes bazelbuild#16706. PiperOrigin-RevId: 489372772 Change-Id: I880e2689f59b2d4420b1e2e0517697d7fb03abbc
1 parent c1c8a6b commit 94355b1

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/main/cpp/blaze.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,10 @@ static vector<string> GetServerExeArgs(const blaze_util::Path &jvm_path,
359359
startup_options.AddJVMArgumentPrefix(jvm_path.GetParent().GetParent(),
360360
&result);
361361

362-
// TODO(b/109998449): only assume JDK >= 9 for embedded JDKs
363-
if (!startup_options.GetEmbeddedJavabase().IsEmpty()) {
364-
// quiet warnings from com.google.protobuf.UnsafeUtil,
365-
// see: https://github.com/google/protobuf/issues/3781
366-
result.push_back("--add-opens=java.base/java.nio=ALL-UNNAMED");
367-
result.push_back("--add-opens=java.base/java.lang=ALL-UNNAMED");
368-
}
362+
// com.google.devtools.build.lib.unsafe.StringUnsafe uses reflection to access
363+
// private fields in java.lang.String. The Bazel server requires Java 11, so
364+
// this option is known to be supported.
365+
result.push_back("--add-opens=java.base/java.lang=ALL-UNNAMED");
369366

370367
result.push_back("-Xverify:none");
371368

0 commit comments

Comments
 (0)