Class Narcissus

java.lang.Object
io.github.toolfactory.narcissus.Narcissus

public class Narcissus
extends java.lang.Object
Narcissus reflection library.
Author:
Luke Hutchison
  • Field Summary

    Fields
    Modifier and Type Field Description
    static boolean libraryLoaded
    Whether or not the library was successfully loaded.
  • Constructor Summary

    Constructors
    Constructor Description
    Narcissus()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.Object allocateInstance​(java.lang.Class<?> cls)
    Allocate an object instance, without calling any constructor.
    static java.util.List<java.lang.reflect.Field> enumerateFields​(java.lang.Class<?> cls)
    Enumerate all fields in the given class, ignoring visibility and bypassing security checks.
    static java.util.List<java.lang.reflect.Method> enumerateMethods​(java.lang.Class<?> cls)
    Enumerate all methods in the given class, ignoring visibility and bypassing security checks.
    static java.lang.Class<?> findClass​(java.lang.String className)
    Finds a class by name (e.g.
    static java.lang.reflect.Constructor<?> findConstructor​(java.lang.Class<?> cls, java.lang.Class<?>... paramTypes)
    Find a constructor by parameter types in the given class, ignoring visibility and bypassing security checks.
    static java.lang.reflect.Field findField​(java.lang.Class<?> cls, java.lang.String fieldName)
    Find a field by name in the given class, ignoring visibility and bypassing security checks.
    static java.lang.reflect.Method findMethod​(java.lang.Class<?> cls, java.lang.String methodName, java.lang.Class<?>... paramTypes)
    Find a method by name and parameter types in the given class, ignoring visibility and bypassing security checks.
    static boolean getBooleanField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of a boolean field, ignoring visibility and bypassing security checks.
    static byte getByteField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of a byte field, ignoring visibility and bypassing security checks.
    static char getCharField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of a char field, ignoring visibility and bypassing security checks.
    static <T> java.lang.reflect.Constructor<T>[] getDeclaredConstructors​(java.lang.Class<T> cls)
    Get declared constructors, ignoring visibility and bypassing security checks.
    static java.lang.reflect.Field[] getDeclaredFields​(java.lang.Class<?> cls)
    Get declared fields, ignoring visibility and bypassing security checks.
    static java.lang.reflect.Method[] getDeclaredMethods​(java.lang.Class<?> cls)
    Get declared methods, ignoring visibility and bypassing security checks.
    static double getDoubleField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of a double field, ignoring visibility and bypassing security checks.
    static java.lang.Object getField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of an object field, ignoring visibility and bypassing security checks, boxing the value if necessary.
    static float getFloatField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of a float field, ignoring visibility and bypassing security checks.
    static int getIntField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of an int field, ignoring visibility and bypassing security checks.
    static long getLongField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of a long field, ignoring visibility and bypassing security checks.
    static java.lang.Object getObjectField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of an object field, ignoring visibility and bypassing security checks.
    static short getShortField​(java.lang.Object object, java.lang.reflect.Field field)
    Get the value of a short field, ignoring visibility and bypassing security checks.
    static boolean getStaticBooleanField​(java.lang.reflect.Field field)
    Get the value of a static boolean field, ignoring visibility and bypassing security checks.
    static byte getStaticByteField​(java.lang.reflect.Field field)
    Get the value of a static byte field, ignoring visibility and bypassing security checks.
    static char getStaticCharField​(java.lang.reflect.Field field)
    Get the value of a static char field, ignoring visibility and bypassing security checks.
    static double getStaticDoubleField​(java.lang.reflect.Field field)
    Get the value of a static double field, ignoring visibility and bypassing security checks.
    static java.lang.Object getStaticField​(java.lang.reflect.Field field)
    Get the value of a static field, ignoring visibility and bypassing security checks, boxing the value if necessary.
    static float getStaticFloatField​(java.lang.reflect.Field field)
    Get the value of a static float field, ignoring visibility and bypassing security checks.
    static int getStaticIntField​(java.lang.reflect.Field field)
    Get the value of a static int field, ignoring visibility and bypassing security checks.
    static long getStaticLongField​(java.lang.reflect.Field field)
    Get the value of a static long field, ignoring visibility and bypassing security checks.
    static java.lang.Object getStaticObjectField​(java.lang.reflect.Field field)
    Get the value of a static object field, ignoring visibility and bypassing security checks.
    static short getStaticShortField​(java.lang.reflect.Field field)
    Get the value of a static short field, ignoring visibility and bypassing security checks.
    static boolean invokeBooleanMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static boolean-return-type method, ignoring visibility and bypassing security checks.
    static byte invokeByteMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static byte-return-type method, ignoring visibility and bypassing security checks.
    static char invokeCharMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static char-return-type method, ignoring visibility and bypassing security checks.
    static double invokeDoubleMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static double-return-type method, ignoring visibility and bypassing security checks.
    static float invokeFloatMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static float-return-type method, ignoring visibility and bypassing security checks.
    static int invokeIntMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static int-return-type method, ignoring visibility and bypassing security checks.
    static long invokeLongMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static long-return-type method, ignoring visibility and bypassing security checks.
    static java.lang.Object invokeMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static Object-return-type method, ignoring visibility and bypassing security checks, boxing the result if necessary.
    static java.lang.Object invokeObjectMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static Object-return-type method, ignoring visibility and bypassing security checks.
    static short invokeShortMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static short-return-type method, ignoring visibility and bypassing security checks.
    static boolean invokeStaticBooleanMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static boolean-return-type method, ignoring visibility and bypassing security checks.
    static byte invokeStaticByteMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static byte-return-type method, ignoring visibility and bypassing security checks.
    static char invokeStaticCharMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static char-return-type method, ignoring visibility and bypassing security checks.
    static double invokeStaticDoubleMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static double-return-type method, ignoring visibility and bypassing security checks.
    static float invokeStaticFloatMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static float-return-type method, ignoring visibility and bypassing security checks.
    static int invokeStaticIntMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static int-return-type method, ignoring visibility and bypassing security checks.
    static long invokeStaticLongMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static long-return-type method, ignoring visibility and bypassing security checks.
    static java.lang.Object invokeStaticMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static Object-return-type method, ignoring visibility and bypassing security checks, boxing the result if necessary.
    static java.lang.Object invokeStaticObjectMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static Object-return-type method, ignoring visibility and bypassing security checks.
    static short invokeStaticShortMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static short-return-type method, ignoring visibility and bypassing security checks.
    static void invokeStaticVoidMethod​(java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a static void-return-type method, ignoring visibility and bypassing security checks.
    static void invokeVoidMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
    Invoke a non-static void-return-type method, ignoring visibility and bypassing security checks.
    static void setBooleanField​(java.lang.Object object, java.lang.reflect.Field field, boolean val)
    Set the value of a boolean field, ignoring visibility and bypassing security checks.
    static void setByteField​(java.lang.Object object, java.lang.reflect.Field field, byte val)
    Set the value of a byte field, ignoring visibility and bypassing security checks.
    static void setCharField​(java.lang.Object object, java.lang.reflect.Field field, char val)
    Set the value of a char field, ignoring visibility and bypassing security checks.
    static void setDoubleField​(java.lang.Object object, java.lang.reflect.Field field, double val)
    Set the value of a double field, ignoring visibility and bypassing security checks.
    static void setField​(java.lang.Object object, java.lang.reflect.Field field, java.lang.Object val)
    Set the value of an object field, ignoring visibility and bypassing security checks, unboxing the passed value if necessary.
    static void setFloatField​(java.lang.Object object, java.lang.reflect.Field field, float val)
    Set the value of a float field, ignoring visibility and bypassing security checks.
    static void setIntField​(java.lang.Object object, java.lang.reflect.Field field, int val)
    Set the value of an int field, ignoring visibility and bypassing security checks.
    static void setLongField​(java.lang.Object object, java.lang.reflect.Field field, long val)
    Set the value of a long field, ignoring visibility and bypassing security checks.
    static void setObjectField​(java.lang.Object object, java.lang.reflect.Field field, java.lang.Object val)
    Set the value of a object field, ignoring visibility and bypassing security checks.
    static void setShortField​(java.lang.Object object, java.lang.reflect.Field field, short val)
    Set the value of a short field, ignoring visibility and bypassing security checks.
    static void setStaticBooleanField​(java.lang.reflect.Field field, boolean val)
    Set the value of a static boolean field, ignoring visibility and bypassing security checks.
    static void setStaticByteField​(java.lang.reflect.Field field, byte val)
    Set the value of a static byte field, ignoring visibility and bypassing security checks.
    static void setStaticCharField​(java.lang.reflect.Field field, char val)
    Set the value of a static char field, ignoring visibility and bypassing security checks.
    static void setStaticDoubleField​(java.lang.reflect.Field field, double val)
    Set the value of a static double field, ignoring visibility and bypassing security checks.
    static void setStaticField​(java.lang.reflect.Field field, java.lang.Object val)
    Set the value of a static field, ignoring visibility and bypassing security checks, unboxing the passed value if necessary.
    static void setStaticFloatField​(java.lang.reflect.Field field, float val)
    Set the value of a static float field, ignoring visibility and bypassing security checks.
    static void setStaticIntField​(java.lang.reflect.Field field, int val)
    Set the value of a static int field, ignoring visibility and bypassing security checks.
    static void setStaticLongField​(java.lang.reflect.Field field, long val)
    Set the value of a static long field, ignoring visibility and bypassing security checks.
    static void setStaticObjectField​(java.lang.reflect.Field field, java.lang.Object val)
    Set the value of a static object field, ignoring visibility and bypassing security checks.
    static void setStaticShortField​(java.lang.reflect.Field field, short val)
    Set the value of a static short field, ignoring visibility and bypassing security checks.
    static void sneakyThrow​(java.lang.Throwable throwable)
    Throw a Throwable without requiring a throws declaration.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • libraryLoaded

      public static final boolean libraryLoaded
      Whether or not the library was successfully loaded. If this value is false, you will get UnsatisfiedLinkError when you try calling methods in this class.
  • Constructor Details

    • Narcissus

      public Narcissus()
  • Method Details

    • findClass

      public static java.lang.Class<?> findClass​(java.lang.String className)
      Finds a class by name (e.g. "com.xyz.MyClass") using the current classloader or the system classloader, ignoring visibility and bypassing security checks. Finds array classes if the class name is of the form "com.xyz.MyClass[][]".
      Parameters:
      className - the class name
      Returns:
      the class reference
    • allocateInstance

      public static java.lang.Object allocateInstance​(java.lang.Class<?> cls)
      Allocate an object instance, without calling any constructor. (For internal use.)
      Parameters:
      cls - the class to instantiate
      Returns:
      the new object instance
    • sneakyThrow

      public static void sneakyThrow​(java.lang.Throwable throwable)
      Throw a Throwable without requiring a throws declaration. (For internal use.)
      Parameters:
      throwable - the Throwable to throw
    • findMethod

      public static java.lang.reflect.Method findMethod​(java.lang.Class<?> cls, java.lang.String methodName, java.lang.Class<?>... paramTypes) throws java.lang.NoSuchMethodException
      Find a method by name and parameter types in the given class, ignoring visibility and bypassing security checks.
      Parameters:
      cls - the class
      methodName - the method name.
      paramTypes - the parameter types of the method.
      Returns:
      the Method
      Throws:
      java.lang.NoSuchMethodException - if the class does not contain a method of the given name
    • findConstructor

      public static java.lang.reflect.Constructor<?> findConstructor​(java.lang.Class<?> cls, java.lang.Class<?>... paramTypes) throws java.lang.NoSuchMethodException
      Find a constructor by parameter types in the given class, ignoring visibility and bypassing security checks.
      Parameters:
      cls - the class
      paramTypes - the parameter types of the constructor.
      Returns:
      the Method
      Throws:
      java.lang.NoSuchMethodException - if the class does not contain a constructor of the given name
    • enumerateMethods

      public static java.util.List<java.lang.reflect.Method> enumerateMethods​(java.lang.Class<?> cls)
      Enumerate all methods in the given class, ignoring visibility and bypassing security checks. Also iterates up through superclasses, to collect all methods of the class and its superclasses.
      Parameters:
      cls - the class
      Returns:
      a list of Method objects representing all methods declared by the class or a superclass.
    • findField

      public static java.lang.reflect.Field findField​(java.lang.Class<?> cls, java.lang.String fieldName) throws java.lang.NoSuchFieldException
      Find a field by name in the given class, ignoring visibility and bypassing security checks.
      Parameters:
      cls - the class
      fieldName - the field name.
      Returns:
      the Field
      Throws:
      java.lang.NoSuchFieldException - if the class does not contain a field of the given name
    • enumerateFields

      public static java.util.List<java.lang.reflect.Field> enumerateFields​(java.lang.Class<?> cls)
      Enumerate all fields in the given class, ignoring visibility and bypassing security checks. Also iterates up through superclasses, to collect all fields of the class and its superclasses.
      Parameters:
      cls - the class
      Returns:
      a list of Field objects representing all fields declared by the class or a superclass.
    • getDeclaredMethods

      public static java.lang.reflect.Method[] getDeclaredMethods​(java.lang.Class<?> cls)
      Get declared methods, ignoring visibility and bypassing security checks.
      Parameters:
      cls - the class
      Returns:
      the declared methods
    • getDeclaredConstructors

      public static <T> java.lang.reflect.Constructor<T>[] getDeclaredConstructors​(java.lang.Class<T> cls)
      Get declared constructors, ignoring visibility and bypassing security checks.
      Type Parameters:
      T - the generic type
      Parameters:
      cls - the class
      Returns:
      the declared constructors
    • getDeclaredFields

      public static java.lang.reflect.Field[] getDeclaredFields​(java.lang.Class<?> cls)
      Get declared fields, ignoring visibility and bypassing security checks.
      Parameters:
      cls - the class
      Returns:
      the declared fields
    • getIntField

      public static int getIntField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of an int field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the int value of the field
    • getLongField

      public static long getLongField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of a long field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the long value of the field
    • getShortField

      public static short getShortField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of a short field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the short value of the field
    • getCharField

      public static char getCharField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of a char field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the char value of the field
    • getBooleanField

      public static boolean getBooleanField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of a boolean field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the boolean value of the field
    • getByteField

      public static byte getByteField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of a byte field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the byte value of the field
    • getFloatField

      public static float getFloatField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of a float field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the float value of the field.
    • getDoubleField

      public static double getDoubleField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of a double field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the double value of the field
    • getObjectField

      public static java.lang.Object getObjectField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of an object field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the value of the field
    • getField

      public static java.lang.Object getField​(java.lang.Object object, java.lang.reflect.Field field)
      Get the value of an object field, ignoring visibility and bypassing security checks, boxing the value if necessary.
      Parameters:
      object - the object instance to get the field value from
      field - the non-static field
      Returns:
      the value of the field
    • setIntField

      public static void setIntField​(java.lang.Object object, java.lang.reflect.Field field, int val)
      Set the value of an int field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the int value to set
    • setLongField

      public static void setLongField​(java.lang.Object object, java.lang.reflect.Field field, long val)
      Set the value of a long field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the long value to set
    • setShortField

      public static void setShortField​(java.lang.Object object, java.lang.reflect.Field field, short val)
      Set the value of a short field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the short value to set
    • setCharField

      public static void setCharField​(java.lang.Object object, java.lang.reflect.Field field, char val)
      Set the value of a char field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the char value to set
    • setBooleanField

      public static void setBooleanField​(java.lang.Object object, java.lang.reflect.Field field, boolean val)
      Set the value of a boolean field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the boolean value to set
    • setByteField

      public static void setByteField​(java.lang.Object object, java.lang.reflect.Field field, byte val)
      Set the value of a byte field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the byte value to set
    • setFloatField

      public static void setFloatField​(java.lang.Object object, java.lang.reflect.Field field, float val)
      Set the value of a float field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the float value to set
    • setDoubleField

      public static void setDoubleField​(java.lang.Object object, java.lang.reflect.Field field, double val)
      Set the value of a double field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the double value to set
    • setObjectField

      public static void setObjectField​(java.lang.Object object, java.lang.reflect.Field field, java.lang.Object val)
      Set the value of a object field, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the value to set
    • setField

      public static void setField​(java.lang.Object object, java.lang.reflect.Field field, java.lang.Object val)
      Set the value of an object field, ignoring visibility and bypassing security checks, unboxing the passed value if necessary.
      Parameters:
      object - the object instance in which to set the field value
      field - the non-static field
      val - the value to set
    • getStaticIntField

      public static int getStaticIntField​(java.lang.reflect.Field field)
      Get the value of a static int field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the int value of the static field
    • getStaticLongField

      public static long getStaticLongField​(java.lang.reflect.Field field)
      Get the value of a static long field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static long field
    • getStaticShortField

      public static short getStaticShortField​(java.lang.reflect.Field field)
      Get the value of a static short field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static short field
    • getStaticCharField

      public static char getStaticCharField​(java.lang.reflect.Field field)
      Get the value of a static char field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static char field
    • getStaticBooleanField

      public static boolean getStaticBooleanField​(java.lang.reflect.Field field)
      Get the value of a static boolean field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static boolean field
    • getStaticByteField

      public static byte getStaticByteField​(java.lang.reflect.Field field)
      Get the value of a static byte field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static byte field
    • getStaticFloatField

      public static float getStaticFloatField​(java.lang.reflect.Field field)
      Get the value of a static float field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static float field
    • getStaticDoubleField

      public static double getStaticDoubleField​(java.lang.reflect.Field field)
      Get the value of a static double field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static double field
    • getStaticObjectField

      public static java.lang.Object getStaticObjectField​(java.lang.reflect.Field field)
      Get the value of a static object field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      Returns:
      the static object field
    • getStaticField

      public static java.lang.Object getStaticField​(java.lang.reflect.Field field)
      Get the value of a static field, ignoring visibility and bypassing security checks, boxing the value if necessary.
      Parameters:
      field - the static field
      Returns:
      the static field
    • setStaticIntField

      public static void setStaticIntField​(java.lang.reflect.Field field, int val)
      Set the value of a static int field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the int value to set
    • setStaticLongField

      public static void setStaticLongField​(java.lang.reflect.Field field, long val)
      Set the value of a static long field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the long value to set
    • setStaticShortField

      public static void setStaticShortField​(java.lang.reflect.Field field, short val)
      Set the value of a static short field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the short value to set
    • setStaticCharField

      public static void setStaticCharField​(java.lang.reflect.Field field, char val)
      Set the value of a static char field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the char value to set
    • setStaticBooleanField

      public static void setStaticBooleanField​(java.lang.reflect.Field field, boolean val)
      Set the value of a static boolean field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the boolean value to set
    • setStaticByteField

      public static void setStaticByteField​(java.lang.reflect.Field field, byte val)
      Set the value of a static byte field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the byte value to set
    • setStaticFloatField

      public static void setStaticFloatField​(java.lang.reflect.Field field, float val)
      Set the value of a static float field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the float value to set
    • setStaticDoubleField

      public static void setStaticDoubleField​(java.lang.reflect.Field field, double val)
      Set the value of a static double field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the double value to set
    • setStaticObjectField

      public static void setStaticObjectField​(java.lang.reflect.Field field, java.lang.Object val)
      Set the value of a static object field, ignoring visibility and bypassing security checks.
      Parameters:
      field - the static field
      val - the value to set
    • setStaticField

      public static void setStaticField​(java.lang.reflect.Field field, java.lang.Object val)
      Set the value of a static field, ignoring visibility and bypassing security checks, unboxing the passed value if necessary.
      Parameters:
      field - the static field
      val - the value to set
    • invokeVoidMethod

      public static void invokeVoidMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static void-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
    • invokeIntMethod

      public static int invokeIntMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static int-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the int return value
    • invokeLongMethod

      public static long invokeLongMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static long-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the long return value
    • invokeShortMethod

      public static short invokeShortMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static short-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the short return value
    • invokeCharMethod

      public static char invokeCharMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static char-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the char return value
    • invokeBooleanMethod

      public static boolean invokeBooleanMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static boolean-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the boolean return value
    • invokeByteMethod

      public static byte invokeByteMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static byte-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the byte return value
    • invokeFloatMethod

      public static float invokeFloatMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static float-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the float return value
    • invokeDoubleMethod

      public static double invokeDoubleMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static double-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the double return value
    • invokeObjectMethod

      public static java.lang.Object invokeObjectMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static Object-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the return value
    • invokeMethod

      public static java.lang.Object invokeMethod​(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a non-static Object-return-type method, ignoring visibility and bypassing security checks, boxing the result if necessary.
      Parameters:
      object - the object instance to invoke the method on
      method - the non-static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the return value (possibly a boxed value)
    • invokeStaticVoidMethod

      public static void invokeStaticVoidMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static void-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
    • invokeStaticIntMethod

      public static int invokeStaticIntMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static int-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the int return value
    • invokeStaticLongMethod

      public static long invokeStaticLongMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static long-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the long return value
    • invokeStaticShortMethod

      public static short invokeStaticShortMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static short-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the short return value
    • invokeStaticCharMethod

      public static char invokeStaticCharMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static char-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the char return value
    • invokeStaticBooleanMethod

      public static boolean invokeStaticBooleanMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static boolean-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the boolean return value
    • invokeStaticByteMethod

      public static byte invokeStaticByteMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static byte-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the byte return value
    • invokeStaticFloatMethod

      public static float invokeStaticFloatMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static float-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the float return value
    • invokeStaticDoubleMethod

      public static double invokeStaticDoubleMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static double-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the double return value
    • invokeStaticObjectMethod

      public static java.lang.Object invokeStaticObjectMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static Object-return-type method, ignoring visibility and bypassing security checks.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the return value
    • invokeStaticMethod

      public static java.lang.Object invokeStaticMethod​(java.lang.reflect.Method method, java.lang.Object... args)
      Invoke a static Object-return-type method, ignoring visibility and bypassing security checks, boxing the result if necessary.
      Parameters:
      method - the static method
      args - the method arguments (or new Object[0] if there are no args)
      Returns:
      the return value (possibly a boxed value)