Class ImplLookupAccessor
java.lang.Object
dev.derklaro.reflexion.internal.handles.ImplLookupAccessor
An accessor to get the IMPL_LOOKUP field using the unsafe field methods provided by the jvm.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable MethodHandles.LookupTries to get the IMPL_LOOKUP using the either direct field access or the methods provided by sun.misc.Unsafe.private static @Nullable MethodHandles.LookupTries to resolve the IMPL_LOOKUP field by direct access, only available on a modern jvm if unnamed modules were granted access to the java.lang.invoke module.(package private) static @Nullable MethodHandles.LookupTries to resolve the IMPL_LOOKUP field using the methods provided by sun.misc.unsafe.(package private) static @Nullable MethodHandles.LookupTries to resolve the IMPL_LOOKUP field using the methods provided by sun.misc.unsafe.
-
Constructor Details
-
ImplLookupAccessor
private ImplLookupAccessor()
-
-
Method Details
-
findImplLookup
Tries to get the IMPL_LOOKUP using the either direct field access or the methods provided by sun.misc.Unsafe.- Returns:
- the IMPL_LOOKUP field value or null if the lookup is not possible.
-
tryResolveUsingDirectAccess
Tries to resolve the IMPL_LOOKUP field by direct access, only available on a modern jvm if unnamed modules were granted access to the java.lang.invoke module.- Returns:
- the IMPL_LOOKUP instance, resolved via direct field access or null if not possible.
-
tryResolveUsingUnsafeGetObject
Tries to resolve the IMPL_LOOKUP field using the methods provided by sun.misc.unsafe. This method only works on a sun jvm and will most likely stop working in further releases of the jvm (20/21/22...) as all methods which are returning field offsets were deprecated and will be removed.- Returns:
- the IMPL_LOOKUP instance, resolved using sun.misc.unsafe or null if not possible.
-
tryResolveUsingUnsafeAccessibleObject
@VisibleForTesting @Nullable static @Nullable MethodHandles.Lookup tryResolveUsingUnsafeAccessibleObject()Tries to resolve the IMPL_LOOKUP field using the methods provided by sun.misc.unsafe. This method only works on a sun jvm and tries to force-override the accessible state of the IMPL_LOOKUP field.- Returns:
- the IMPL_LOOKUP instance or null if not possible.
- Since:
- 1.6
-