In Java there is the Unsafe
class in the java.lang.unsafe package that provides low-level access to operations.
Now it seems to me that the JVM needs to support all of the methods available in the Unsafe
class in order to be compliant to the JLS, example methods can be found here.
Examples of the operations Unsafe
provides and JVMs need to support in order to be compliant to the JLS would be:
- Working with objects
- Storing data (of type int, long, byte, etc.)
- Retrieving data
- Working with monitors
- Working with memory fences
- etc.
My question now is: Why can we not find the Unsafe
class in a java.* package? Is there a specific reason why it would be better that every JVM provider creates their own sun.misc.unsafe.Unsafe variant instead of writing an implementation for a class defined in the java.* package?