Bazel crash: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module

5,636 views
Skip to first unread message

Ilmari Lauhakangas

unread,
Dec 3, 2021, 6:24:06 AM12/3/21
to Repo and Gerrit Discussion
I am building gerrit master branch on Arch Linux with Bazel 4.2.0. I changed the version in .bazelversion. Below is the command I used and the output. What might be the cause of the crash?

Regards,
Ilmari Lauhakangas

$ bazel build --define=ABSOLUTE_JAVABASE=/usr/lib/jvm/java-11-openjdk :release
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 3dac6dcf-3253-4731-a62c-9597560a8cdc
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=236
INFO: Reading rc options for 'build' from /home/user/gerrit/.bazelrc:
  'build' options: --workspace_status_command=python3 ./tools/workspace_status.py --repository_cache=~/.gerritcodereview/bazel-cache/repository --action_env=PATH --disk_cache=~/.gerritcodereview/bazel-cache/cas --java_toolchain=//tools:error_prone_warnings_toolchain_java11 --incompatible_strict_action_env --announce_rc --experimental_worker_multiplex=false
DEBUG: /home/user/.cache/bazel/_bazel_user/83c970f1736ebd133fa7a3c282913f0b/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:68:14:
Current running Bazel is ahead of bazel-toolchains repo. Please update your pin to bazel-toolchains repo in your WORKSPACE file.
DEBUG: /home/user/.cache/bazel/_bazel_user/83c970f1736ebd133fa7a3c282913f0b/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:125:14: rbe_jdk11 not using checked in configs; Bazel version 4.2.0 was picked/selected but no checked in config was found in map {"0.20.0": ["8.0.0"], "0.21.0": ["8.0.0"], "0.22.0": ["8.0.0", "9.0.0"], "0.23.0": ["8.0.0", "9.0.0"], "0.23.1": ["8.0.0", "9.0.0"], "0.23.2": ["9.0.0"], "0.24.0": ["9.0.0"], "0.24.1": ["9.0.0"], "0.25.0": ["9.0.0"], "0.25.1": ["9.0.0"], "0.25.2": ["9.0.0"], "0.26.0": ["9.0.0"], "0.26.1": ["9.0.0"], "0.27.0": ["9.0.0"], "0.27.1": ["9.0.0"], "0.28.0": ["9.0.0"], "0.28.1": ["9.0.0"], "0.29.0": ["9.0.0"], "0.29.1": ["9.0.0", "10.0.0"], "1.0.0": ["9.0.0", "10.0.0"], "1.0.1": ["10.0.0"], "1.1.0": ["10.0.0"], "1.2.0": ["10.0.0"], "1.2.1": ["10.0.0"], "2.0.0": ["10.0.0"], "2.1.0": ["10.0.0"], "2.1.1": ["10.0.0", "11.0.0"], "2.2.0": ["11.0.0"], "3.0.0": ["11.0.0"], "3.1.0": ["11.0.0"], "3.2.0": ["11.0.0"], "3.3.0": ["11.0.0"], "3.3.1": ["11.0.0"], "3.4.1": ["11.0.0"], "3.5.0": ["11.0.0"], "3.5.1": ["11.0.0"], "3.6.0": ["11.0.0"], "3.7.0": ["11.0.0"], "3.7.1": ["11.0.0"], "3.7.2": ["11.0.0"], "4.0.0": ["11.0.0"]}
INFO: Analyzed target //:release (517 packages loaded, 20371 targets configured).
INFO: Found 1 target...
[807 / 1,070] 11 actions, 8 running
    Compiling src/google/protobuf/compiler/cpp/cpp_file.cc; 2s remote-cache, linux-sandbox
    Executing genrule //plugins/codemirror-editor:codemirror-element; 1s remote-cache, linux-sandbox
    Compiling TypeScript project //plugins/delete-project/web:delete-project-ts [tsc -p plugins/delete-project/web/tsconfig.json]; 1s remote-cache, linux-sandbox
    Compiling TypeScript project //polygerrit-ui/app:compile_pg [tsc -p polygerrit-ui/app/tsconfig_bazel.json]; 0s remote-cache, linux-sandbox
    Action external/bazel_tools/tools/jdk/platformclasspath.jar [for host]; 1s remote-cache
    [Prepa] Compiling Java headers java/com/google/gerrit/index/libquery_exception-hjar.jar (2 source files)
    [Prepa] Building java/com/google/gerrit/common/libversion-class.jar ()
FATAL: bazel crashed due to an internal error. Printing stack trace:
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.actions.CommandLines$ParamFileActionInput.writeTo(CommandLines.java:275)
        at com.google.devtools.build.lib.remote.util.DigestUtil.compute(DigestUtil.java:68)
        at com.google.devtools.build.lib.remote.merkletree.DirectoryTreeBuilder.lambda$buildFromActionInputs$1(DirectoryTreeBuilder.java:129)
        at com.google.devtools.build.lib.remote.merkletree.DirectoryTreeBuilder.build(DirectoryTreeBuilder.java:201)
        at com.google.devtools.build.lib.remote.merkletree.DirectoryTreeBuilder.buildFromActionInputs(DirectoryTreeBuilder.java:123)
        at com.google.devtools.build.lib.remote.merkletree.DirectoryTreeBuilder.fromActionInputs(DirectoryTreeBuilder.java:62)
        at com.google.devtools.build.lib.remote.merkletree.MerkleTree.build(MerkleTree.java:140)
        at com.google.devtools.build.lib.remote.RemoteExecutionService.buildRemoteAction(RemoteExecutionService.java:242)
        at com.google.devtools.build.lib.remote.RemoteSpawnCache.lookup(RemoteSpawnCache.java:97)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:139)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:106)
        at com.google.devtools.build.lib.actions.SpawnStrategy.beginExecution(SpawnStrategy.java:47)
        at com.google.devtools.build.lib.exec.SpawnStrategyResolver.beginExecution(SpawnStrategyResolver.java:65)
        at com.google.devtools.build.lib.rules.java.JavaCompileAction.beginExecution(JavaCompileAction.java:357)
        at com.google.devtools.build.lib.actions.Action.execute(Action.java:127)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:855)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1016)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:975)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:129)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:81)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:472)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:834)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:307)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:477)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:398)
        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 @635eaaf1
        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)
        ... 30 more

Ilmari Lauhakangas

unread,
Dec 8, 2021, 9:34:02 AM12/8/21
to Repo and Gerrit Discussion
On Friday, December 3, 2021 at 1:24:06 PM UTC+2 Ilmari Lauhakangas wrote:
I am building gerrit master branch on Arch Linux with Bazel 4.2.0. I changed the version in .bazelversion. Below is the command I used and the output. What might be the cause of the crash?


Hmh, seems so far to be specific to (this) Arch Linux as I just tested in a VM with Debian Testing and with Bazelisk it builds fine with Bazel 4.0.0 and 4.2.2.
 

Ilmari Lauhakangas

unread,
Dec 8, 2021, 10:31:49 AM12/8/21
to Repo and Gerrit Discussion

So this gets me past the problem:
bazel --host_jvm_args=--add-opens=java.base/java.nio=ALL-UNNAMED --host_jvm_args=--add-opens=java.base/java.lang=ALL-UNNAMED build --define=ABSOLUTE_JAVABASE=/usr/lib/jvm/java-11-openjdk :release

However, now the build fails with this (--verbose_failures):
ERROR: /home/user/gerrit/plugins/delete-project/BUILD:10:14: Building plugins/delete-project/libdelete-project__plugin-class.jar (21 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor, AutoOneOfProcessor, AutoValueGsonAdapterFactoryProcessor) failed: (Exit 1): java failed: error executing command
  (cd /home/user/.cache/bazel/_bazel_user/83c970f1736ebd133fa7a3c282913f0b/execroot/gerrit && \
  exec env - \
    LC_CTYPE=en_US.UTF-8 \
    PATH=/home/user/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl \
  external/remotejdk11_linux/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--patch-module=java.compiler=external/remote_java_tools_linux/java_tools/java_compiler.jar' '--patch-module=jdk.compiler=external/remote_java_tools_linux/java_tools/jdk_compiler.jar' '--add-opens=java.base/java.nio=ALL-UNNAMED' '--add-opens=java.base/java.lang=ALL-UNNAMED' -jar external/remote_java_tools_linux/java_tools/JavaBuilder_deploy.jar @bazel-out/k8-fastbuild/bin/plugins/delete-project/libdelete-project__plugin-class.jar-0.params @bazel-out/k8-fastbuild/bin/plugins/delete-project/libdelete-project__plugin-class.jar-1.params)
Execution platform: @local_config_platform//:host
plugins/delete-project/src/main/java/com/googlesource/gerrit/plugins/deleteproject/DeleteCommand.java:31: error: [InlineFormatString] Prefer to create format strings inline, instead of extracting them to a single-use constant
  private static final String REALLY_DELETE =
                              ^
    (see https://errorprone.info/bugpattern/InlineFormatString)
  Did you mean to remove this line?
plugins/delete-project/src/main/java/com/googlesource/gerrit/plugins/deleteproject/DeleteCommand.java:29: error: [InlineFormatString] Prefer to create format strings inline, instead of extracting them to a single-use constant
  private static final String FORCE_DELETE =
                              ^
    (see https://errorprone.info/bugpattern/InlineFormatString)
  Did you mean to remove this line?

Ilmari Lauhakangas

unread,
Dec 14, 2021, 6:03:18 AM12/14/21
to Repo and Gerrit Discussion
I think this might have been due to not having done 'git submodule update' or maybe it was some bug that slipped through. In any case, after pulling and updating submodules I can build Gerrit on Arch Linux just fine!

I reported the openjdk packaging issue at https://bugs.archlinux.org/task/72985

Ilmari
Reply all
Reply to author
Forward
0 new messages