...
This section deconstructs how exact invocation of MethodHandles are compiled, linked and executed using a specific example of setting the value of a non-static field. Examples of byte code and inlining traces are obtained by compiling and executing a MethodHandle
-based jmh
micro-benchmark.
Despite the name a Methodhandle
MethodHandle
can reference an underlying static or instance field of class. In the OpenJDK implementation invocations of such handles result in a corresponding call to an a method on sun.misc.Unsafe
, after appropriate safety checks have been performed. For example, if the field is a reference type (a non-primitive type) marked as volatile then the method Unsafe.putObjectVolatile
will be invoked.
...