public class ReflectionUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
MAX_NEST_DEPTH
The constant MAX_NEST_DEPTH.
|
| 构造器和说明 |
|---|
ReflectionUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Class<?> |
getClassByName(String className)
Gets class by name.
|
static Object |
getFieldValue(Object target,
String fieldName)
get Field Value
|
static Set<Class<?>> |
getInterfaces(Class<?> clazz)
get all interface of the clazz
|
static Method |
getMethod(Class<?> classType,
String methodName,
Class<?>[] parameterTypes)
get Method by name
|
static Object |
invokeMethod(Object target,
String methodName)
invoke Method
|
static Object |
invokeMethod(Object target,
String methodName,
Class<?>[] parameterTypes,
Object[] args)
invoke Method
|
static Object |
invokeStaticMethod(Class<?> targetClass,
String methodName,
Class<?>[] parameterTypes,
Object[] parameterValues)
invoke static Method
|
public static final int MAX_NEST_DEPTH
public static Class<?> getClassByName(String className) throws ClassNotFoundException
className - the class nameClassNotFoundException - the class not found exceptionpublic static Object getFieldValue(Object target, String fieldName) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
target - the targetfieldName - the field nameNoSuchFieldException - the no such field exceptionSecurityException - the security exceptionIllegalArgumentException - the illegal argument exceptionIllegalAccessException - the illegal access exceptionpublic static Object invokeMethod(Object target, String methodName) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
target - the targetmethodName - the method nameNoSuchMethodException - the no such method exceptionSecurityException - the security exceptionIllegalAccessException - the illegal access exceptionIllegalArgumentException - the illegal argument exceptionInvocationTargetException - the invocation target exceptionpublic static Object invokeMethod(Object target, String methodName, Class<?>[] parameterTypes, Object[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
target - the targetmethodName - the method nameparameterTypes - the parameter typesargs - the argsNoSuchMethodException - the no such method exceptionSecurityException - the security exceptionIllegalAccessException - the illegal access exceptionIllegalArgumentException - the illegal argument exceptionInvocationTargetException - the invocation target exceptionpublic static Object invokeStaticMethod(Class<?> targetClass, String methodName, Class<?>[] parameterTypes, Object[] parameterValues) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
targetClass - the target classmethodName - the method nameparameterTypes - the parameter typesparameterValues - the parameter valuesNoSuchMethodException - the no such method exceptionSecurityException - the security exceptionIllegalAccessException - the illegal access exceptionIllegalArgumentException - the illegal argument exceptionInvocationTargetException - the invocation target exceptionpublic static Method getMethod(Class<?> classType, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException, SecurityException
classType - the class typemethodName - the method nameparameterTypes - the parameter typesNoSuchMethodException - the no such method exceptionSecurityException - the security exceptionCopyright © 2019 Seata. All rights reserved.