private Object invokeReflectMethod(Class clazz, String methodName, Object[] paras)
throws SecurityException,
NoSuchMethodException,
IllegalArgumentException,
IllegalAccessException,
InvocationTargetException, InstantiationException {
Class c[]=null;
if(paras!=null){//存在
int len=paras.length;
c=new Class[len];
for(int i=0;i<len;++i){
c[i]=paras[i].getClass();
}
}
Method method = clazz.getDeclaredMethod(methodName, c);
if(!method.isAccessible()) {
method.setAccessible(true);
}
return method.invoke(clazz, c);
}
java反射方法
最新推荐文章于 2024-08-11 09:51:52 发布