zoukankan      html  css  js  c++  java
  • 反射的调用接口的写法:

    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;

    public  static <T> T callStaticObjectMethod(Class<?> clazz, Class<T> returnType, String method, Class<?>[] parameterTypes,
    Object... values)
    throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    Method declaredMethod = clazz.getDeclaredMethod(method, parameterTypes);
    declaredMethod.setAccessible(true);
    return (T) declaredMethod.invoke(null, values);
    }
    private static final String PHONE_ENCRYPT_UTIL_CLASS = "com.miui.enterprise.PhoneEncryptUtil";
    private static boolean isEncryptedNumber(String number) {
    try {
    Class phoneEncryptUtil = Class.forName(PHONE_ENCRYPT_UTIL_CLASS);
    return callStaticObjectMethod(phoneEncryptUtil, boolean.class, "isEncryptedNumber",
    new Class[]{String.class}, number);
    } catch (Exception e) {
    return false;
    }
    }
  • 相关阅读:
    alpha冲刺3
    alpha冲刺2
    alpha冲刺1
    软工第七次作业
    软工第八次作业
    软工第六次作业
    软工第五次作业
    软工第四次作业
    Alpha冲刺一 (2/10)
    Alpha冲刺一(1/10)
  • 原文地址:https://www.cnblogs.com/liunx1109/p/10594528.html
Copyright © 2011-2022 走看看