Skip to content

"A terminally deprecated method in sun.misc.Unsafe has been called" #4229

Open

Description

@hills

With the latest commits, and today's download from Oracle, the following error is omitted towards the end of JavaScript compilation:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by com.google.common.hash.LittleEndianByteArray$UnsafeByteArray (file:/scratch/mark/cache/bazel/_bazel_mark/d465ce32b1ece8e176cd9a6c173f6b09/execroot/_main/bazel-out/k8-fastbuild/bin/compiler_uberjar_deploy.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.common.hash.LittleEndianByteArray$UnsafeByteArray
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
closure-compiler$ git describe --long
v20250317-0-g455c10971
$ java --version
java 24 2025-03-18
Java(TM) SE Runtime Environment (build 24+36-3646)
Java HotSpot(TM) 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)

Activity

  1. added
    triage-doneHas been reviewed by someone on triage rotation.
    internal-issue-createdAn internal Google issue has been created to track this GitHub issue
    on Mar 21, 2025
  2. rishipal commented on Mar 24, 2025

    @rishipal
    Contributor

    What project are you trying to compile? How do I reproduce this?

  3. hills commented on Mar 24, 2025

    @hills
    Author

    To reproduce, just install the latest java from Oracle (downloads)

    It displays the warning with any JavaScript input, for example a blank input:

    $ echo '' | /path/to/java -jar /path/to/closure-compiler-v20240317.jar
    The compiler is waiting for input via stdin.
    WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
    WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor (file:/opt/google/closure-compiler/closure-compiler-v20240317.jar)
    WARNING: Please consider reporting this to the maintainers of class com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor
    WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
    

    It's also reproducible with the latest master of Closure Compiler.

  4. niloc132 commented on Mar 24, 2025

    @niloc132
    Contributor

    From the errors, this is coming both from guava and protobuf. I don't yet see a guava issue tracking it, but for protobuf there's protocolbuffers/protobuf#20760.

    Guava line in latest: https://github.com/google/guava/blob/2aaa4548ec1d4dfcde6a98d1d8a87dbd4810a38d/guava/src/com/google/common/hash/LittleEndianByteArray.java#L249

    If I'm reading both of those properly, failure to access these will not break the tool, though it will result in these logs.

    According to JEP 498, this will log a warning in Java 24, then in Java 26 (or later) this will start to throw. To suppress the warning, the JVM arg --sun-misc-unsafe-memory-access=allow can be passed at least through Java 26 to continue to allow this without warnings.

  5. lauraharker commented on Mar 26, 2025

    @lauraharker
    Contributor

    We'll wait for Guava & protobuf to fix this - we can upgrade then, or if that doesn't happen & we want to move to Java 21, suppress this.

    We're currently on Java 21 specifically to align with how this is built internally within Google.

  6. AngelTs commented on Apr 19, 2025

    @AngelTs

    Same warning issues:
    WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
    WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor (file:/.../closure-compiler-v20250402.jar)
    WARNING: Please consider reporting this to the maintainers of class com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor
    WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release

    java --version
    java 24 2025-03-18
    Java(TM) SE Runtime Environment (build 24+36-3646)
    Java HotSpot(TM) 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)

  7. ChadKillingsworth commented on May 31, 2025

    @ChadKillingsworth
    Contributor

    Since this error is emitted by the JRE when executed (as opposed to just a build time), I'm adding the suppression flag to the npm library. Unfortunately that flag is unrecognized before JDK 24, so you have to also ignore unrecognized flags.

  8. ChadKillingsworth commented on Jun 1, 2025

    @ChadKillingsworth
    Contributor

    Guava reports that it is fixed: google/guava#7811

  9. juj commented on Jun 28, 2025

    @juj

    I got this same error today:

    WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
    WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by com.google.common.hash.LittleEndianByteArray$UnsafeByteArray (file:/C:/buildbot/win11-arm64-8gb-snapdragon-7c/emscripten_win11_arm64/build/emscripten/main/node_modules/google-closure-compiler-java/compiler.jar)
    WARNING: Please consider reporting this to the maintainers of class com.google.common.hash.LittleEndianByteArray$UnsafeByteArray
    WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
    

    Downgrading from Java 24 down to Java 21 avoided this issue.

  10. martindholmes commented on Oct 26, 2026

    @martindholmes

    Just flagging up that this is still happening with the brand-new release today, using the default Java on Ubuntu 26.04 (Java 25). Since this is supposed to be fixed in Guava, should we still be seeing the error?

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

Metadata

Metadata

Assignees

Labels

internal-issue-createdAn internal Google issue has been created to track this GitHub issuetriage-doneHas been reviewed by someone on triage rotation.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions