sun.misc.Unsafe memory access deprecated

Java 23 Course · lesson 9 of 15 · 4 min read

The long goodbye to the API half the ecosystem secretly depends on.

Open this lesson in the learning hub

Key points

  • sun.misc.Unsafe was never public API, but Netty, Cassandra and countless libraries use it.
  • JEP 471 deprecates its memory-access methods for removal, starting a multi-release wind-down.
  • The supported replacements already exist: VarHandle for fields, the FFM API for off-heap memory.
  • You will usually hit this through a dependency, not your own code, so upgrade libraries early.
  • Warnings appear first, then the methods throw, then they disappear - do not wait for the last step.

You will meet the Unsafe removal through your dependencies, so track their JDK support, not just your own code.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Java 23 Course course, and every lesson in it is listed on the Java 23 Course contents page.