public class ReflectionHelper
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectionHelper.UnableToAccessFieldException |
static class |
ReflectionHelper.UnableToFindClassException |
static class |
ReflectionHelper.UnableToFindFieldException |
static class |
ReflectionHelper.UnableToFindMethodException |
static class |
ReflectionHelper.UnknownConstructorException |
| Constructor and Description |
|---|
ReflectionHelper() |
| 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... fieldNames) |
static java.lang.reflect.Method |
findMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.String methodObfName,
java.lang.Class<?>... parameterTypes)
Finds a method with the specified name and parameters in the given class and makes it accessible.
|
static java.lang.Class<? super java.lang.Object> |
getClass(java.lang.ClassLoader loader,
java.lang.String... classNames) |
static <T,E> T |
getPrivateValue(java.lang.Class<? super E> classToAccess,
E instance,
int fieldIndex) |
static <T,E> T |
getPrivateValue(java.lang.Class<? super E> classToAccess,
E instance,
java.lang.String... fieldNames) |
static <T,E> void |
setPrivateValue(java.lang.Class<? super T> classToAccess,
T instance,
E value,
int fieldIndex) |
static <T,E> void |
setPrivateValue(java.lang.Class<? super T> classToAccess,
T instance,
E value,
java.lang.String... fieldNames) |
public static java.lang.reflect.Field findField(java.lang.Class<?> clazz,
java.lang.String... fieldNames)
public static <T,E> T getPrivateValue(java.lang.Class<? super E> classToAccess,
@Nullable
E instance,
int fieldIndex)
public static <T,E> T getPrivateValue(java.lang.Class<? super E> classToAccess,
E instance,
java.lang.String... fieldNames)
public static <T,E> void setPrivateValue(java.lang.Class<? super T> classToAccess,
T instance,
E value,
int fieldIndex)
public static <T,E> void setPrivateValue(java.lang.Class<? super T> classToAccess,
T instance,
E value,
java.lang.String... fieldNames)
public static java.lang.Class<? super java.lang.Object> getClass(java.lang.ClassLoader loader,
java.lang.String... classNames)
@Nonnull
public static java.lang.reflect.Method findMethod(@Nonnull
java.lang.Class<?> clazz,
@Nonnull
java.lang.String methodName,
@Nullable
java.lang.String methodObfName,
java.lang.Class<?>... parameterTypes)
Throws an exception if the method is not found.
clazz - The class to find the method on.methodName - The name of the method to find (used in developer environments, i.e. "getWorldTime").methodObfName - The obfuscated name of the method to find (used in obfuscated environments, i.e. "func_72820_D").
If the name you are looking for is on a class that is never obfuscated, this should be null.parameterTypes - The parameter types of the method to find.@Nonnull
public static <T> java.lang.reflect.Constructor<T> findConstructor(@Nonnull
java.lang.Class<T> klass,
@Nonnull
java.lang.Class<?>... parameterTypes)
T - The typeklass - The class to find the constructor inparameterTypes - The parameter types of the constructor.java.lang.NullPointerException - if klass is nulljava.lang.NullPointerException - if parameterTypes is nullReflectionHelper.UnknownConstructorException - if the constructor could not be found