/**
*
* 反射实现
*
* */
public static boolean invokeTest(String className, String methodName,
Class<?>[] parmList)
{
boolean isExist = false;
try {
Class<?> mClass = Class.forName(className);
/* Method[] methodList = mClass.getMethods();
for(Method method : methodList)
{
LogUtils.logDebug(true, method.getName());
if(methodName.equals(method.getName()))
{
isExist = true;
Class<?>[] sClasses = method.getParameterTypes();
break;
}
}*/
Method mMethod = null;
try {
mMethod = mClass.getMethod(methodName,
new Class<?>[]{int.class, String.class});
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
try {
mMethod.invoke(mClass.newInstance(), 2,<span style="font-family:Arial, Helvetica, sans-serif;">methodName);</span>
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return isExist;
}
/**
*
* 要调用的函数
*
* */
public void test(int arg1, String arg2)
{
LogUtils.logDebug(true, "invoke test arg1:" + arg1 + " arg2:" + arg2);
}
/**
*
* 反射调用
*
* */
invokeTest("org.zywx.wbpalmstar.plugin.utils.UIConfig",
"test", new Class[]{int.class, String.class});