public final class ReflectUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ARRAY_DESC |
static String |
CLASS_DESC |
static Pattern |
DESC_PATTERN |
static String |
DESC_REGEX |
static Class<?>[] |
EMPTY_CLASS_ARRAY |
static Pattern |
GETTER_METHOD_DESC_PATTERN |
static Pattern |
IS_HAS_CAN_METHOD_DESC_PATTERN |
static String |
JAVA_IDENT_REGEX |
static String |
JAVA_NAME_REGEX |
static char |
JVM_BOOLEAN
boolean(Z).
|
static char |
JVM_BYTE
byte(B).
|
static char |
JVM_CHAR
char(C).
|
static char |
JVM_DOUBLE
double(D).
|
static char |
JVM_FLOAT
float(F).
|
static char |
JVM_INT
int(I).
|
static char |
JVM_LONG
long(J).
|
static char |
JVM_SHORT
short(S).
|
static char |
JVM_VOID
void(V).
|
static Pattern |
METHOD_DESC_PATTERN |
static String |
METHOD_DESC_REGEX |
static Pattern |
SETTER_METHOD_DESC_PATTERN |
| Modifier and Type | Method and Description |
|---|---|
static Class<?> |
desc2class(String desc)
desc to class.
|
static Class<?>[] |
desc2classArray(String desc)
get class array instance.
|
static String |
desc2name(String desc)
desc to name.
|
static Constructor<?> |
findConstructor(Class<?> clazz,
Class<?> paramType) |
static Method |
findMethodByMethodName(Class<?> clazz,
String methodName) |
static Method |
findMethodByMethodSignature(Class<?> clazz,
String methodName,
String[] parameterTypes)
Find method from method signature
|
static Class<?> |
forName(String name) |
static Map<String,Field> |
getBeanPropertyFields(Class cl) |
static Map<String,Method> |
getBeanPropertyReadMethods(Class cl) |
static Class<?> |
getBoxedClass(Class<?> c) |
static String |
getCodeBase(Class<?> cls) |
static String |
getDesc(Class<?> c)
get class desc.
|
static String |
getDesc(Class<?>[] cs)
get class array desc.
|
static String |
getDesc(Constructor<?> c)
get constructor desc.
|
static String |
getDesc(javassist.CtClass c)
get class desc.
|
static String |
getDesc(javassist.CtConstructor c)
get constructor desc.
|
static String |
getDesc(javassist.CtMethod m)
get method desc.
|
static String |
getDesc(Method m)
get method desc.
|
static String |
getDescWithoutMethodName(javassist.CtMethod m)
get method desc.
|
static String |
getDescWithoutMethodName(Method m)
get method desc.
|
static Object |
getEmptyObject(Class<?> returnType) |
static Class<?> |
getGenericClass(Class<?> cls) |
static Class<?> |
getGenericClass(Class<?> cls,
int i) |
static String |
getName(Class<?> c)
get name.
|
static String |
getName(Constructor<?> c)
get constructor name.
|
static String |
getName(Method m)
get method name.
|
static String |
getPropertyNameFromBeanReadMethod(Method method) |
static String |
getPropertyNameFromBeanWriteMethod(Method method) |
static String |
getSignature(String methodName,
Class<?>[] parameterTypes) |
static boolean |
isBeanPropertyReadMethod(Method method) |
static boolean |
isBeanPropertyWriteMethod(Method method) |
static boolean |
isCompatible(Class<?>[] cs,
Object[] os)
is compatible.
|
static boolean |
isCompatible(Class<?> c,
Object o)
is compatible.
|
static boolean |
isInstance(Object obj,
String interfaceClazzName)
Check if one object is the implementation for a given interface.
|
static boolean |
isPrimitive(Class<?> cls) |
static boolean |
isPrimitives(Class<?> cls) |
static boolean |
isPublicInstanceField(Field field) |
static Class<?> |
name2class(String name)
name to class.
|
static String |
name2desc(String name)
name to desc.
|
public static final char JVM_VOID
public static final char JVM_BOOLEAN
public static final char JVM_BYTE
public static final char JVM_CHAR
public static final char JVM_DOUBLE
public static final char JVM_FLOAT
public static final char JVM_INT
public static final char JVM_LONG
public static final char JVM_SHORT
public static final Class<?>[] EMPTY_CLASS_ARRAY
public static final String JAVA_IDENT_REGEX
public static final String JAVA_NAME_REGEX
public static final String CLASS_DESC
public static final String ARRAY_DESC
public static final String DESC_REGEX
public static final Pattern DESC_PATTERN
public static final String METHOD_DESC_REGEX
public static final Pattern METHOD_DESC_PATTERN
public static final Pattern GETTER_METHOD_DESC_PATTERN
public static final Pattern SETTER_METHOD_DESC_PATTERN
public static final Pattern IS_HAS_CAN_METHOD_DESC_PATTERN
public static boolean isPrimitives(Class<?> cls)
public static boolean isPrimitive(Class<?> cls)
public static boolean isCompatible(Class<?> c, Object o)
c - class.o - instance.public static boolean isCompatible(Class<?>[] cs, Object[] os)
cs - class array.os - object array.public static String getName(Class<?> c)
c - class.public static String getName(Method m)
m - method.public static String getName(Constructor<?> c)
c - constructor.public static String getDesc(Class<?> c)
c - class.javassist.NotFoundExceptionpublic static String getDesc(Class<?>[] cs)
cs - class array.javassist.NotFoundExceptionpublic static String getDesc(Method m)
m - method.public static String getDesc(Constructor<?> c)
c - constructor.public static String getDescWithoutMethodName(Method m)
m - method.public static String getDesc(javassist.CtClass c) throws javassist.NotFoundException
c - class.javassist.NotFoundExceptionpublic static String getDesc(javassist.CtMethod m) throws javassist.NotFoundException
m - method.javassist.NotFoundExceptionpublic static String getDesc(javassist.CtConstructor c) throws javassist.NotFoundException
c - constructor.javassist.NotFoundExceptionpublic static String getDescWithoutMethodName(javassist.CtMethod m) throws javassist.NotFoundException
m - method.javassist.NotFoundExceptionpublic static String name2desc(String name)
name - name.public static String desc2name(String desc)
desc - desc.public static Class<?> name2class(String name) throws ClassNotFoundException
name - name.ClassNotFoundExceptionpublic static Class<?> desc2class(String desc) throws ClassNotFoundException
desc - desc.ClassNotFoundExceptionpublic static Class<?>[] desc2classArray(String desc) throws ClassNotFoundException
desc - desc.ClassNotFoundExceptionpublic static Method findMethodByMethodSignature(Class<?> clazz, String methodName, String[] parameterTypes) throws NoSuchMethodException, ClassNotFoundException
clazz - Target class to find methodmethodName - Method signature, e.g.: method1(int, String). It is allowed to provide method name only, e.g.: method2NoSuchMethodExceptionClassNotFoundExceptionIllegalStateException - when multiple methods are found (overridden method when parameter info is not provided)public static Method findMethodByMethodName(Class<?> clazz, String methodName) throws NoSuchMethodException, ClassNotFoundException
public static Constructor<?> findConstructor(Class<?> clazz, Class<?> paramType) throws NoSuchMethodException
NoSuchMethodExceptionpublic static boolean isInstance(Object obj, String interfaceClazzName)
This method will not trigger classloading for the given interface, therefore it will not lead to error when the given interface is not visible by the classloader
obj - Object to examineinterfaceClazzName - The given interfacepublic static boolean isBeanPropertyReadMethod(Method method)
public static String getPropertyNameFromBeanReadMethod(Method method)
public static boolean isBeanPropertyWriteMethod(Method method)
public static String getPropertyNameFromBeanWriteMethod(Method method)
public static boolean isPublicInstanceField(Field field)
Copyright © 2011–2018 The Apache Software Foundation. All rights reserved.