You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"A terminally deprecated method in sun.misc.Unsafe has been called" #4229
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
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.
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.
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.
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)
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.
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.
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?
Activity
rishipal commentedon Mar 24, 2025
What project are you trying to compile? How do I reproduce this?
hills commentedon Mar 24, 2025
To reproduce, just install the latest java from Oracle (downloads)
It displays the warning with any JavaScript input, for example a blank input:
It's also reproducible with the latest master of Closure Compiler.
niloc132 commentedon Mar 24, 2025
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=allowcan be passed at least through Java 26 to continue to allow this without warnings.lauraharker commentedon Mar 26, 2025
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.
AngelTs commentedon Apr 19, 2025
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
ChadKillingsworth commentedon May 31, 2025
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.
ChadKillingsworth commentedon Jun 1, 2025
Guava reports that it is fixed: google/guava#7811
juj commentedon Jun 28, 2025
I got this same error today:
Downgrading from Java 24 down to Java 21 avoided this issue.
martindholmes commentedon Oct 26, 2026
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?