Bazel 5.1.1 with openjdk17 server
See original GitHub issueDescription of the bug:
If using openjdk17 as bazel server runtime some actions may fail
java.lang.ExceptionInInitializerError
at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:118)
at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:111)
at com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction$ParamFileWriter.writeOutputFile(ParameterFileWriteAction.java:170)
at com.google.devtools.build.lib.exec.FileWriteStrategy.beginWriteOutputToFile(FileWriteStrategy.java:58)
at com.google.devtools.build.lib.analysis.actions.FileWriteActionContext.beginWriteOutputToFile(FileWriteActionContext.java:49)
at com.google.devtools.build.lib.analysis.actions.AbstractFileWriteAction.beginExecution(AbstractFileWriteAction.java:66)
at com.google.devtools.build.lib.actions.Action.execute(Action.java:133)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:907)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1076)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1031)
at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:152)
at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:91)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:492)
at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:856)
at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:349)
at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:169)
at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:590)
at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module @5e3c3cb
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:75)
at com.google.devtools.build.lib.unsafe.StringUnsafe.initInstance(StringUnsafe.java:56)
at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:37)
... 21 more
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Haven’t minimized this yet, also not yet tested with newer bazel releases
Which operating system are you running Bazel on?
NixOS
What is the output of bazel info release
?
release 5.1.1- (@non-git)
If bazel info release
returns development version
or (@non-git)
, tell us how you built Bazel.
NixOS nixpkgs
What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD
?
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
https://openjdk.org/jeps/403 since java16 default is
-illegal-access=deny disables all illegal-access operations except for those enabled by other command-line options, e.g., --add-opens.
Something like --add-opens=java.base/java.lang=ALL-UNNAMED
for server jvm flags could be a workaround
somewhat related https://github.com/bazelbuild/bazel/issues/5599
reflection is still present in latest bazel source code https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/unsafe/StringUnsafe.java
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Getting started - Bazel 5.1.1
This page contains resources that help you get started with Bazel, including installation steps and container information. It also provides links to tutorials ......
Read more >Semaphore Changelog
Semaphore Changelog#. Thank you for using Semaphore! We continuously deploy changes that improve our product for our customers.
Read more >Running Bazel in offline mode ? (bazel 5.1.1, Tensor 2.9.1 ...
I am trying to install Tensor 2.9.1 using bazel 5.1.1 on Centos via ... [2022-07-21T10:46:34.873Z] [0m[91mStarting local Bazel server and ...
Read more >What's New in Bazel 5.0 - BuildBuddy
Remote caching. Using a remote cache is one of the most popular ways of speeding up a Bazel build. Thankfully these changes make...
Read more >Building with Bazel | Kodeco, the new raywenderlich.com
The largest and most up-to-date collection of courses and books on iOS, Swift, Android, Kotlin, Flutter, Dart, Server-Side Swift, Unity, and more! ©...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The same issue happens for me with Bazel 5.3 and OpenJDK 17,
StringUnsafe
’s constructor fails with anjava.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module
error:This is https://openjdk.org/jeps/403
The workaround is to pass
--add-opens=java.base/java.nio=ALL-UNNAMED
as a server JVM flag. The bazel launcher already passes that flag, but only for embedded JDKs:https://github.com/bazelbuild/bazel/blob/03ad0cd1203b7b54ec02ea3f5788d1d673a9d6d6/src/main/cpp/blaze.cc#L362-L367