April 2018
Intermediate to advanced
910 pages
33h 21m
English
The sun.misc.Unsafe class, like other sun classes, is not officially documented or supported. It has been used to circumvent some of Java's built-in memory management safety features. While this can be viewed as a window to greater control and flexibility in our code, it is a terrible programming practice.
The class had a single private constructor, so an instance of the class could not easily be instantiated. So, if we tried to instantiate an instance with myUnsafe = new Unsafe(), a SecurityException would be thrown in most circumstances. This somewhat unreachable class has over 100 methods that permitted operations on arrays, classes, and objects. Here is a brief sampling of those methods:
| Arrays | Classes ... |