private void dump(final Object o) { try { final Class<?> clazz = o.getClass(); for (final Field field : clazz.getDeclaredFields()) { SetAccessible.on(field); if (Collection.class.isAssignableFrom(field.getType())) { final Collection collection = (Collection) field.get(o); System.out.println(field.getName() + "\t= " + collection.size()); } } } catch (Exception e) { // no-op } }
public static <T extends AccessibleObject> T on(final T object) { return (T) AccessController.doPrivileged(new SetAccessible(object)); } }
private void dump(final Object o) { try { final Class<?> clazz = o.getClass(); for (final Field field : clazz.getDeclaredFields()) { SetAccessible.on(field); if (Collection.class.isAssignableFrom(field.getType())) { final Collection collection = (Collection) field.get(o); System.out.println(field.getName() + "\t= " + collection.size()); } } } catch (Exception e) { // no-op } }
public static <T extends AccessibleObject> T on(T object){ return (T) AccessController.doPrivileged(new SetAccessible(object)); } }
private static void add(final ClassFinder finder, final Set<Method> methods, final Class<? extends Annotation> annotation) { final List<Method> annotatedMethods = finder.findAnnotatedMethods(annotation); for (final Method method : annotatedMethods) { SetAccessible.on(method); methods.add(method); } }
public static <T extends AccessibleObject> T on(final T object) { return (T) AccessController.doPrivileged(new SetAccessible(object)); } }
private static void add(final ClassFinder finder, final Set<Method> methods, final Class<? extends Annotation> annotation) { final List<Method> annotatedMethods = finder.findAnnotatedMethods(annotation); for (final Method method : annotatedMethods) { SetAccessible.on(method); methods.add(method); } }
/** * Used by toMethods and toCallbacks to find the nearest java.lang.reflect.Method with the given * name and parameters. Callbacks can be private so class.getMethod() cannot be used. Searching * starts by looking in the specified class, if the method is not found searching continues with * the immediate parent and continues recurssively until the method is found or java.lang.Object * is reached. If the method is not found a NoSuchMethodException is thrown. * * @param clazz * @param methodName * @param parameterTypes * @return * @throws NoSuchMethodException if the method is not found in this class or any of its parent classes */ private Method getMethod(Class<?> clazz, final String methodName, final Class<?>... parameterTypes) throws NoSuchMethodException { NoSuchMethodException original = null; while (clazz != null) { try { final Method method = clazz.getDeclaredMethod(methodName, parameterTypes); return SetAccessible.on(method); } catch (final NoSuchMethodException e) { if (original == null) { original = e; } } clazz = clazz.getSuperclass(); } throw original; }
/** * Finds the nearest java.lang.reflect.Method with the given * name and parameters. Callbacks can be private so class.getMethod() cannot be used. Searching * starts by looking in the specified class, if the method is not found searching continues with * the immediate parent and continues recurssively until the method is found or java.lang.Object * is reached. If the method is not found a NoSuchMethodException is thrown. * * @param clazz * @param methodName * @param parameterTypes * @return * @throws NoSuchMethodException if the method is not found in this class or any of its parent classes */ private Method getMethod(Class clazz, String methodName, Class... parameterTypes) throws NoSuchMethodException { NoSuchMethodException original = null; while (clazz != null){ try { Method method = clazz.getDeclaredMethod(methodName, parameterTypes); return SetAccessible.on(method); } catch (NoSuchMethodException e) { if (original == null) original = e; } clazz = clazz.getSuperclass(); } throw original; }
/** * Used by toMethods and toCallbacks to find the nearest java.lang.reflect.Method with the given * name and parameters. Callbacks can be private so class.getMethod() cannot be used. Searching * starts by looking in the specified class, if the method is not found searching continues with * the immediate parent and continues recurssively until the method is found or java.lang.Object * is reached. If the method is not found a NoSuchMethodException is thrown. * * @param clazz * @param methodName * @param parameterTypes * @return * @throws NoSuchMethodException if the method is not found in this class or any of its parent classes */ private Method getMethod(Class clazz, String methodName, Class... parameterTypes) throws NoSuchMethodException { NoSuchMethodException original = null; while (clazz != null){ try { Method method = clazz.getDeclaredMethod(methodName, parameterTypes); return SetAccessible.on(method); } catch (NoSuchMethodException e) { if (original == null) original = e; } clazz = clazz.getSuperclass(); } throw original; }
/** * Used by toMethods and toCallbacks to find the nearest java.lang.reflect.Method with the given * name and parameters. Callbacks can be private so class.getMethod() cannot be used. Searching * starts by looking in the specified class, if the method is not found searching continues with * the immediate parent and continues recurssively until the method is found or java.lang.Object * is reached. If the method is not found a NoSuchMethodException is thrown. * * @param clazz * @param methodName * @param parameterTypes * @return * @throws NoSuchMethodException if the method is not found in this class or any of its parent classes */ private Method getMethod(Class<?> clazz, final String methodName, final Class<?>... parameterTypes) throws NoSuchMethodException { NoSuchMethodException original = null; while (clazz != null) { try { final Method method = clazz.getDeclaredMethod(methodName, parameterTypes); return SetAccessible.on(method); } catch (final NoSuchMethodException e) { if (original == null) { original = e; } } clazz = clazz.getSuperclass(); } throw original; }
try { final Method method = clazz.getDeclaredMethod(info.methodName, parameters); return SetAccessible.on(method); } catch (final NoSuchMethodException e) { if (noSuchMethod == null) {
try { final Method method = clazz.getDeclaredMethod(info.methodName, parameters); return SetAccessible.on(method); } catch (final NoSuchMethodException e) { if (noSuchMethod == null) {
final Method p = objectClass.getDeclaredMethod(destroyMethod); if (!p.isAccessible()) { SetAccessible.on(p);
final Method p = objectClass.getDeclaredMethod(destroyMethod); if (!p.isAccessible()) { SetAccessible.on(p);
SetAccessible.on(method); methods.add(method);
SetAccessible.on(method); methods.add(method);
SetAccessible.on(method); methods.add(method);
SetAccessible.on(method); methods.add(method);
SetAccessible.on(method); methods.add(method);