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; }
public static Object getPrivateField( String fieldName, Class<PathfinderGoalSelector> clazz, Object object) { Field field; Object o = null; try { field = clazz.getDeclaredField(fieldName); field.setAccessible(true); o = field.get(object); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return o; }