コード例 #1
0
  public static Object getPrivateValue(Class class1, Object obj, String s)
      throws IllegalArgumentException, SecurityException, NoSuchFieldException {
    try {
      Field field = class1.getDeclaredField(s);
      field.setAccessible(true);
      return field.get(obj);
    } catch (IllegalAccessException illegalaccessexception) {
      modinstance.CELogAgent.logInfo("Can't assign a public field!");
    }

    return null;
  }
コード例 #2
0
  public static Object getPrivateMethod(Class class1, Object obj, String s)
      throws IllegalAccessException, InvocationTargetException, NoSuchMethodException,
          SecurityException {
    try {
      Method method = class1.getDeclaredMethod(s);
      method.setAccessible(true);
      return method.invoke(obj);
    } catch (IllegalAccessException illegalaccessexception) {
      modinstance.CELogAgent.logInfo("Can't assign a private value to a method");
    }

    return null;
  }