private static Field getField(final Class<?> clazz, final String name) { try { final Field field = clazz.getDeclaredField(name); field.setAccessible(true); return field; } catch (Exception e) { e.printStackTrace(); return null; } }
private static Method getMethod(final Class<?> clazz, final String name, final Class<?>... args) { Method[] methods; for (int length = (methods = clazz.getMethods()).length, i = 0; i < length; ++i) { final Method m = methods[i]; if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args, m.getParameterTypes()))) { m.setAccessible(true); return m; } } return null; }