Example #1
0
 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;
   }
 }
Example #2
0
  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;
  }