Class ReflectionUtils

java.lang.Object
com.fastasyncworldedit.core.util.ReflectionUtils

public class ReflectionUtils extends Object
This is an internal class not meant to be used outside the FAWE internals.
  • Constructor Details

    • ReflectionUtils

      public ReflectionUtils()
  • Method Details

    • as

      public static <T> T as(Class<T> t, Object o)
    • compareAndSet

      public static <T> boolean compareAndSet(T[] array, T expectedValue, T newValue, int index)
      Performs CAS on the array element at the given index.
      Type Parameters:
      T - the type of elements in the array
      Parameters:
      array - the array in which to compare and set the value
      expectedValue - the value expected to be at the index
      newValue - the new value to be set at the index if the expected value matches
      index - the index at which to compare and set the value
      Returns:
      true if the value at the index was successfully updated to the new value, false otherwise
      See Also:
    • setAccessibleNonFinal

      public static void setAccessibleNonFinal(Field field)
    • setFailsafeFieldValue

      public static void setFailsafeFieldValue(Field field, Object target, Object value) throws IllegalAccessException
      Throws:
      IllegalAccessException
    • getHandle

      public static Object getHandle(Object wrapper)
    • makeMethod

      public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... parameters)
    • callMethod

      public static <T> T callMethod(Method method, Object instance, Object... parameters)
    • setAccessible

      public static <T extends AccessibleObject> T setAccessible(T ao)
    • getField

      public static <T> T getField(@Nonnull Field field, Object instance)
    • getClass

      public static Class<?> getClass(String name)
    • getClass

      public static <T> Class<? extends T> getClass(String name, Class<T> superClass)
    • unsafeSet

      public static void unsafeSet(Field field, Object base, Object value)
    • getUnsafe

      public static sun.misc.Unsafe getUnsafe()
      Returns:
      an instance of Unsafe