Package com.fastasyncworldedit.core.util
Class ReflectionUtils
java.lang.Object
com.fastasyncworldedit.core.util.ReflectionUtils
This is an internal class not meant to be used outside the FAWE internals.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
static <T> T
callMethod
(Method method, Object instance, Object... parameters) static <T> boolean
compareAndSet
(T[] array, T expectedValue, T newValue, int index) Performs CAS on the array element at the given index.static Class
<?> static <T> Class
<? extends T> static <T> T
static Object
static sun.misc.Unsafe
static Method
makeMethod
(Class<?> clazz, String methodName, Class<?>... parameters) static <T extends AccessibleObject>
TsetAccessible
(T ao) static void
setAccessibleNonFinal
(Field field) static void
setFailsafeFieldValue
(Field field, Object target, Object value) static void
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
as
-
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 valueexpectedValue
- the value expected to be at the indexnewValue
- the new value to be set at the index if the expected value matchesindex
- 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
-
setFailsafeFieldValue
public static void setFailsafeFieldValue(Field field, Object target, Object value) throws IllegalAccessException - Throws:
IllegalAccessException
-
getHandle
-
makeMethod
-
callMethod
-
setAccessible
-
getField
-
getClass
-
getClass
-
unsafeSet
-
getUnsafe
public static sun.misc.Unsafe getUnsafe()- Returns:
- an instance of
Unsafe
-