public class ObfuscationReflectionHelper
extends java.lang.Object
Constructor and Description |
---|
ObfuscationReflectionHelper() |
Modifier and Type | Method and Description |
---|---|
static <T> java.lang.reflect.Constructor<T> |
findConstructor(java.lang.Class<T> klass,
java.lang.Class<?>... parameterTypes)
Finds a constructor in the specified class that has matching parameter types.
|
static java.lang.reflect.Field |
findField(java.lang.Class<?> clazz,
java.lang.String srgName)
Finds a field with the specified name in the given class and makes it accessible.
|
static java.lang.reflect.Method |
findMethod(java.lang.Class<?> clazz,
java.lang.String srgName,
java.lang.Class<?> returnType,
java.lang.Class<?>... parameterTypes)
Finds a method with the specified name and parameters in the given class and makes it accessible.
|
static <T,E> T |
getPrivateValue(java.lang.Class<? super E> classToAccess,
E instance,
int fieldIndex)
Deprecated.
|
static <T,E> T |
getPrivateValue(java.lang.Class<? super E> classToAccess,
E instance,
java.lang.String... fieldNames)
Deprecated.
|
static <T,E> T |
getPrivateValue(java.lang.Class<? super E> classToAccess,
E instance,
java.lang.String srgName) |
private static java.lang.String |
remapFieldName(java.lang.Class<?> clazz,
java.lang.String fieldName) |
static java.lang.String[] |
remapFieldNames(java.lang.String className,
java.lang.String... fieldNames)
Deprecated.
|
private static java.lang.String |
remapMethodName(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?> returnType,
java.lang.Class<?>... parameterTypes) |
static <T,E> void |
setPrivateValue(java.lang.Class<? super T> classToAccess,
T instance,
E value,
int fieldIndex)
Deprecated.
|
static <T,E> void |
setPrivateValue(java.lang.Class<? super T> classToAccess,
T instance,
E value,
java.lang.String... fieldNames)
Deprecated.
|
static <T,E> void |
setPrivateValue(java.lang.Class<? super T> classToAccess,
T instance,
E value,
java.lang.String srgName) |
@Deprecated public static <T,E> T getPrivateValue(java.lang.Class<? super E> classToAccess, E instance, int fieldIndex)
@Deprecated public static java.lang.String[] remapFieldNames(java.lang.String className, java.lang.String... fieldNames)
private static java.lang.String remapFieldName(java.lang.Class<?> clazz, java.lang.String fieldName)
private static java.lang.String remapMethodName(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?> returnType, java.lang.Class<?>... parameterTypes)
@Deprecated public static <T,E> T getPrivateValue(java.lang.Class<? super E> classToAccess, E instance, java.lang.String... fieldNames)
getPrivateValue(Class, Object, String)
public static <T,E> T getPrivateValue(java.lang.Class<? super E> classToAccess, @Nullable E instance, java.lang.String srgName)
@Deprecated public static <T,E> void setPrivateValue(java.lang.Class<? super T> classToAccess, T instance, E value, int fieldIndex)
@Deprecated public static <T,E> void setPrivateValue(java.lang.Class<? super T> classToAccess, T instance, E value, java.lang.String... fieldNames)
setPrivateValue(Class, Object, Object, String)
public static <T,E> void setPrivateValue(java.lang.Class<? super T> classToAccess, @Nullable T instance, @Nullable E value, java.lang.String srgName)
public static java.lang.reflect.Field findField(java.lang.Class<?> clazz, java.lang.String srgName)
Throws an exception if the field is not found.
clazz
- The class to find the field on.srgName
- The obfuscated name of the field to find.public static java.lang.reflect.Method findMethod(java.lang.Class<?> clazz, java.lang.String srgName, java.lang.Class<?> returnType, java.lang.Class<?>... parameterTypes)
Throws an exception if the method is not found.
clazz
- The class to find the method on.srgName
- The obfuscated name of the method to find.returnType
- The return type of the method to find.parameterTypes
- The parameter types of the method to find.public static <T> java.lang.reflect.Constructor<T> findConstructor(java.lang.Class<T> klass, java.lang.Class<?>... parameterTypes)
T
- The typeklass
- The class to find the constructor inparameterTypes
- The parameter types of the constructor.