Skip to content

Illegal reflective access by com.google.protobuf.UnsafeUtil  #5599

Closed

Description

@buchgr

After having upgraded Bazel's protobuf to 3.6.0 and Bazel's JDK to 9, we are seeing these warnings wen building protobufs. It's an annoying cosmetic issue.

INFO: From Compiling Java headers src/main/java/com/google/devtools/build/lib/windows/libwindows-hjar.jar (3 files):
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/usr/local/google/home/buchgr/.cache/bazel/_bazel_buchgr/install/e676aae4e6c63bf8d7cfde16175ea874/_embedded_binaries/embedded_tools/tools/jdk/turbine_deploy.jar) to field java.lang.String.value
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
INFO: From Compiling Java headers src/main/java/com/google/devtools/build/lib/libunix-hjar.jar (10 files) [for host]:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/usr/local/google/home/buchgr/.cache/bazel/_bazel_buchgr/install/e676aae4e6c63bf8d7cfde16175ea874/_embedded_binaries/embedded_tools/tools/jdk/turbine_deploy.jar) to field java.lang.String.value
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
...

Any thoughts @cushon @rongjiecomputer? Can we possibly prevent them from being printed? The corresponding protobuf issue: protocolbuffers/protobuf#3781

Activity

  1. rongjiecomputer commented on Jul 16, 2018

    @rongjiecomputer
    Contributor

    My local workaround is adding build --jvmopt=--add-opens=java.base/java.nio=ALL-UNNAMED to .bazelrc.

  2. cushon commented on Jul 23, 2018

    @cushon
    Contributor

    @buchgr the toolchain includes JVM flags that are supposed to quiet those warnings, but I guess they aren't working:

    "--add-opens=java.base/java.nio=ALL-UNNAMED",

  3. cushon commented on Jul 23, 2018

    @cushon
    Contributor

    Ah, we also want --add-opens=java.base/java.lang=ALL-UNNAMED.

  4. added a commit that references this issue on Aug 2, 2018
    c5eb8fc
  5. jowagner commented on Aug 29, 2018

    @jowagner

    This may be more than just cosmetic. I get this error when trying to build bazel with compile.sh. A few lines after the above error, it says:

    ERROR: /build/src/main/java/com/google/devtools/build/lib/BUILD:1417:1: Building src/main/java/com/google/devtools/build/lib/bazel/BazelServer.jar () failed: Worker process returned an unparseable WorkResponse!
    
    Did you try to print something to stdout? Workers aren't allowed to do this, as it breaks the protocol between Bazel and the worker process.
    

    See also issue protocolbuffers/protobuf#5008

  6. cushon commented on Aug 30, 2018

    @cushon
    Contributor

    I'd expect those warnings to be printed to stderr, not stdout, so they shouldn't affect workers.

  7. jowagner commented on Sep 1, 2018

    @jowagner

    I applied the patch 543918d to bazel-0.16.1-dist.zip and still get the "Illegal reflective access" warning followed by the error in my above comment (this time in "src/java_tools/junitrunner/java/com/google/testing/junit/runner/BUILD:52:1") when running bash ./compile.sh. While the error may be unrelated to issue #5599, shouldn't the warning go away with the patch?

  8. jowagner commented on Sep 1, 2018

    @jowagner

    Found issue #6009 that discusses the broken workers. Both warning and error go away when using JDK 8 instead of 11. One should read https://docs.bazel.build/versions/master/install-compile-source.html each time when compiling on a new system.

  9. connesso commented on Oct 4, 2018

    @connesso

    Tried to install tensorflow with Bazel 0.17.2

    [7,813 / 12,405] 32 actions running
        Compiling tensorflow/stream_executor/stream.cc [for host]; 50s local
        Compiling tensorflow/core/util/batch_util.cc [for host]; 50s local
        Compiling tensorflow/core/distributed_runtime/master_session.cc; 34s local
        Compiling tensorflow/core/common_runtime/direct_session.cc; 30s local
        Compiling tensorflow/core/kernels/remote_fused_graph_execute_utils.cc; 29s local
        Compiling tensorflow/core/kernels/argmax_op.cc; 29s local
        Compiling tensorflow/core/kernels/argmax_op_gpu.cu.cc; 29s local
        Compiling tensorflow/core/kernels/l2loss_op_gpu.cu.cc; 28s local ...
    
    Server terminated abruptly (error code: 14, error message: '', log file: '/home/xxx/.cache/bazel/_bazel_xxx/1ac92dbf7fec9d8d5e9cfda761e288d7/server/jvm.out')
    
    xxx@yyy:~/tensorflow$ cat /home/xxx/.cache/bazel/_bazel_xxx/1ac92dbf7fec9d8d5e9cfda761e288d7/server/jvm.out
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/home/xxx/.cache/bazel/_bazel_xxx/install/792a28b07894763eaa2bd870f8776b23/_embedded_binaries/A-server.jar) to field java.lang.String.value
    WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    

    So it doesn't seem just cosmetic...

  10. andreamlin commented on Nov 2, 2018

    @andreamlin

    I had run into these same errors, along with the Server terminated abruptly (error code: 14, error message: '', log file: .../jvm.out` message, but it turns out that I was just getting an out-of-memory error while running the bazel target in a CircleCI container with limited memory. After constraining bazel to run with a smaller memory footprint (tips from SO), the target built as expected.

  11. NelsonPython commented on Nov 30, 2018

    @NelsonPython

    Ubuntu 18.04.1 Server, JDK 8
    Attempting to load bazel using:
    ./bazel-0.18.0-installer-linux-x86_64.sh --user
    worked great last week. now get

    Build informations

    • [Commit] (d13df47)
      Uncompressing...WARNING: An illegal reflective access operation has occurred
      WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil

    Can't load bazel - any ideas?

  12. jlturriff commented on Feb 27, 2020

    @jlturriff

    I'm getting it also while trying to build tensorflow in my OpenSuSE Leap 15.1 system:

    /usr/local/tensorflow-master
    █ ./configure
    WARNING: detected http_proxy set in env, setting no_proxy for localhost.
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/root/.cache/bazel/_bazel_root/install/73e92e4d21505d8fa81af652d5c23b82/_embedded_binaries/A-server.jar) to field java.nio.Buffer.address
    WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    INFO: Options provided by the client:
      Inherited 'common' options: --isatty=1 --terminal_columns=159
    INFO: Reading rc options for 'version' from /usr/local/tensorflow-master/.bazelrc:
      Inherited 'common' options: --experimental_repo_remote_exec
    ERROR: Unrecognized option: --experimental_repo_remote_exec
    WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
    INFO: Invocation ID: 3fdad2d2-f19c-41b0-bbcd-dec1ce9c73eb
    Traceback (most recent call last):
      File "./configure.py", line 1548, in <module>
        main()
      File "./configure.py", line 1368, in main
        _TF_MAX_BAZEL_VERSION)
      File "./configure.py", line 483, in check_bazel_version
        ['bazel', '--batch', '--bazelrc=/dev/null', 'version'])
      File "./configure.py", line 159, in run_shell
        output = subprocess.check_output(cmd, stderr=stderr)
      File "/usr/lib64/python2.7/subprocess.py", line 219, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['bazel', '--batch', '--bazelrc=/dev/null', 'version']' returned non-zero exit status 2
    
    
  13. jowagner commented on Feb 27, 2020

    @jowagner

    @jlturriff Did you try using JDK 8 (available in the openSUSE default repo) instead of 11? Also note "Illegal reflective access" is only a warning. Your output shows a proper error "Unrecognized option: --experimental_repo_remote_exec" that may have a different cause than what is discussed here. Searching for this string may help you find a solution. My guess is that your bazel is too old.

  14. jlturriff commented on Feb 28, 2020

    @jlturriff
  15. Leslie-Fang commented on Mar 9, 2020

    @Leslie-Fang

    I have used bazel-1.2.1 and get the same error:

    ERROR: Unrecognized option: --experimental_repo_remote_exec
    
  16. jowagner commented on Mar 9, 2020

    @jowagner

    @jlturriff and @Leslie-Fang Please open an issue "Build process requires too recent build tools" on https://github.com/tensorflow/tensorflow . The tensorflow developers are likely to close it quickly with "wontfix" but it is good to move the discussion from here to a dedicated space. Please cross-link here, e.g. by referring to this conversation in your bug report. (Github automatically creates a back-link.)

  17. jlturriff commented on Mar 10, 2020

    @jlturriff

    Done, except for the cross-link. (How do I do that?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions