Zero-Allocation-Hashing icon indicating copy to clipboard operation
Zero-Allocation-Hashing copied to clipboard

Any plan to remove `Unsafe` usage ?

Open counter2015 opened this issue 8 months ago • 3 comments

Projects that rely on this library will receive warnings when running in JDK 24 version.

refer: https://github.com/sbt/sbt/issues/8073

WARNING: Please consider reporting this to the maintainers of class net.openhft.hashing.UnsafeAccess
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
WARNING: A restricted method in java.lang.System has been called

Is there any plan to remove Unsafe usage?

see also: https://foojay.io/today/unsafe-is-finally-going-away-embracing-safer-memory-access-with-jep-471/

counter2015 avatar Mar 19 '25 07:03 counter2015

A major user of this library is parquet-java, see related issue. I hope the issue can be solved in this repo by the Zero-Allocation-Hashing maintainers.

pradn avatar Apr 09 '25 19:04 pradn

The memory access APIs in sun.misc.Unsafe were deprecated in JDK 23. They are scheduled to be REMOVED from the JDK after JDK 26.

lizlooney avatar Apr 09 '25 22:04 lizlooney

VarHandle was discussed and profiled in #67 and the results are different on environments. This unsafe functions called by this project are pluggable behind Access interface.

We could have two implementations, UnsafeAccess and VarHandleAccess. In building stage, use an separated module for UnsafeAccess to build with JDK<23. In the runtime, select a proper access instance based on the running JDK/JRE or the user configs.

gzm55 avatar Apr 10 '25 00:04 gzm55