Code example for Method

Methods: isAccessible, setAccessible

0
    } 
 
    public static Method getMethod(Class<?> containerType, String name)
            throws NoSuchMethodException { 
        try { 
            return containerType.getDeclaredMethod(name);
        } catch (NoSuchMethodException e) {
            Class<?> superClass = containerType.getSuperclass();
            if (superClass == null) {
                throw e;
            } 
            return getMethod(superClass, name);
        } 
    } 
 
    public static Field getField(Class<?> containerType, String name)
            throws NoSuchFieldException { 
        try { 
            return containerType.getDeclaredField(name);
        } catch (NoSuchFieldException e) {
            Class<?> superClass = containerType.getSuperclass();