org.apache.cxf.common.util

## Class ReflectionUtil

- java.lang.Object
- - org.apache.cxf.common.util.ReflectionUtil

-     public final class ReflectionUtil
      extends Object

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> T` | `accessDeclaredField(Field f, Object o, Class<T> responseClass)`
    `static Method` | `findMethod(Class<?> cls, String name, Class<?>... params)` Try to find a method we can use.
    `static <T extends Annotation> T` | `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 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 List<String>` | `getPackagesFromJar(File jarFile)`
    `static PropertyDescriptor[]` | `getPropertyDescriptorsAvoidSunBug(Class<?> refClass, BeanInfo beanInfo, Class<?> beanClass, PropertyDescriptor[] propertyDescriptors)` create own array of property descriptors to:
    `static <T extends AccessibleObject> T` | `setAccessible(T o)`
    `static <T extends AccessibleObject> T` | `setAccessible(T o, boolean b)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### accessDeclaredField

          public static <T> T accessDeclaredField(Field f,
                                  Object o,
                                  Class<T> responseClass)

    - #### getDeclaredField

          public static Field getDeclaredField(Class<?> cls,
                               String name)

    - #### getDeclaredConstructor

          public static <T> Constructor<T> getDeclaredConstructor(Class<T> cls,
                                                  Class<?>... args)

    - #### getConstructor

          public static <T> Constructor<T> getConstructor(Class<T> cls,
                                          Class<?>... args)

    - #### getDeclaredMethods

          public static Method[] getDeclaredMethods(Class<?> cls)

    - #### getDeclaredMethod

          public static Method getDeclaredMethod(Class<?> clazz,
                                 String name,
                                 Class<?>... parameterTypes)
                                          throws NoSuchMethodException

      Throws:
        `NoSuchMethodException`

    - #### getDeclaredFields

          public static Field[] getDeclaredFields(Class<?> cls)

    - #### setAccessible

          public static <T extends AccessibleObject> T setAccessible(T o)

    - #### setAccessible

          public static <T extends AccessibleObject> T setAccessible(T o,
                                                     boolean b)

    - #### getPackagesFromJar

          public static List<String> getPackagesFromJar(File jarFile)
                                                 throws IOException

      Throws:
        `IOException`

    - #### getPropertyDescriptorsAvoidSunBug

          public static PropertyDescriptor[] getPropertyDescriptorsAvoidSunBug(Class<?> refClass,
                                                               BeanInfo beanInfo,
                                                               Class<?> beanClass,
                                                               PropertyDescriptor[] propertyDescriptors)

      create own array of property descriptors to:

            - 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

      Parameters:
        `refClass` - calling class for class loading.
        `beanInfo` - Bean in question
        `beanClass` - class for bean in question
        `propertyDescriptors` - raw descriptors

    - #### findMethod

          public static Method findMethod(Class<?> cls,
                          String name,
                          Class<?>... params)

      Try to find a method we can use. If the object implements a public interface that has the public version of that method, we'll use the interface defined method in case the actual instance class is not public

    - #### getAnnotationForMethodOrContainingClass

          public static <T extends Annotation> T getAnnotationForMethodOrContainingClass(Method m,
                                                                         Class<T> annotationType)

      Look for a specified annotation on a method. If there, return it. If not, search it's containing class. Assume that the annotation is marked @Inherited.
      Parameters:
        `m` - method to examine
        `annotationType` - the annotation type to look for.

Apache CXF