public final class ReflectionUtil extends Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
accessDeclaredField(Field f,
Object o,
Class<T> responseClass) |
static <T> T |
accessDeclaredField(String fieldName,
Class<?> cls,
Object o,
Class<T> responseClass) |
static <T extends Annotation> |
getAnnotationForMethodOrContainingClass(Method m,
Class<T> annotationType)
Look for a specified annotation on a method.
|
static <T> Constructor<T> |
getConstructor(Class<T> cls,
Class<?>... args) |
static <T> Constructor<T> |
getDeclaredConstructor(Class<T> cls,
Class<?>... args) |
static <T> Constructor<T>[] |
getDeclaredConstructors(Class<T> cls) |
static Field |
getDeclaredField(Class<?> cls,
String name) |
static Field[] |
getDeclaredFields(Class<?> cls) |
static Method |
getDeclaredMethod(Class<?> clazz,
String name,
Class<?>... parameterTypes) |
static Method[] |
getDeclaredMethods(Class<?> cls) |
static PropertyDescriptor[] |
getPropertyDescriptorsAvoidSunBug(Class<?> refClass,
BeanInfo beanInfo,
Class<?> beanClass,
PropertyDescriptor[] propertyDescriptors)
create own array of property descriptors to:
|
static <T extends AccessibleObject> |
setAccessible(T o) |
static <T extends AccessibleObject> |
setAccessible(T o,
boolean b) |
public static <T> T accessDeclaredField(Field f, Object o, Class<T> responseClass)
public static <T> T accessDeclaredField(String fieldName, Class<?> cls, Object o, Class<T> responseClass)
public static <T> Constructor<T> getDeclaredConstructor(Class<T> cls, Class<?>... args)
public static <T> Constructor<T> getConstructor(Class<T> cls, Class<?>... args)
public static <T> Constructor<T>[] getDeclaredConstructors(Class<T> cls)
public static Method getDeclaredMethod(Class<?> clazz, String name, Class<?>... parameterTypes) throws NoSuchMethodException
NoSuchMethodException
public static <T extends AccessibleObject> T setAccessible(T o)
public static <T extends AccessibleObject> T setAccessible(T o, boolean b)
public static PropertyDescriptor[] getPropertyDescriptorsAvoidSunBug(Class<?> refClass, BeanInfo beanInfo, Class<?> beanClass, PropertyDescriptor[] propertyDescriptors)
- prevent memory leaks by Introspector's cache - get correct type for generic properties from superclass that are limited to a specific type in beanClass see http://bugs.sun.com/view_bug.do?bug_id=6528714 we cannot use BeanUtils.getPropertyDescriptors because of issue SPR-6063
refClass
- calling class for class loading.beanInfo
- Bean in questionbeanClass
- class for bean in questionpropertyDescriptors
- raw descriptorspublic static <T extends Annotation> T getAnnotationForMethodOrContainingClass(Method m, Class<T> annotationType)
m
- method to examineannotationType
- the annotation type to look for.Apache CXF