Class UnsafeAccess


  • public final class UnsafeAccess
    extends java.lang.Object
    Static access to Unsafe and convenient utility methods for performing low-level, unsafe operations.

    Warning: This class is scheduled for removal in version 3.0.0.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String ANDROID  
      (package private) static java.lang.String OPEN_JDK  
      static sun.misc.Unsafe UNSAFE
      The Unsafe instance.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private UnsafeAccess()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static sun.misc.Unsafe load​(java.lang.String openJdk, java.lang.String android)  
      static long objectFieldOffset​(java.lang.Class<?> clazz, java.lang.String fieldName)
      Returns the location of a given static field.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UNSAFE

        public static final sun.misc.Unsafe UNSAFE
        The Unsafe instance.
    • Constructor Detail

      • UnsafeAccess

        private UnsafeAccess()
    • Method Detail

      • objectFieldOffset

        public static long objectFieldOffset​(java.lang.Class<?> clazz,
                                             java.lang.String fieldName)
        Returns the location of a given static field.
        Parameters:
        clazz - the class containing the field
        fieldName - the name of the field
        Returns:
        the address offset of the field
      • load

        static sun.misc.Unsafe load​(java.lang.String openJdk,
                                    java.lang.String android)
                             throws java.lang.NoSuchMethodException,
                                    java.lang.SecurityException,
                                    java.lang.InstantiationException,
                                    java.lang.IllegalAccessException,
                                    java.lang.IllegalArgumentException,
                                    java.lang.reflect.InvocationTargetException
        Throws:
        java.lang.NoSuchMethodException
        java.lang.SecurityException
        java.lang.InstantiationException
        java.lang.IllegalAccessException
        java.lang.IllegalArgumentException
        java.lang.reflect.InvocationTargetException