public static Method getDeclaredMethod(Object object, String methodName, Class<?> ... parameterTypes){
Method method = null ;
for(Class<?> clazz = object.getClass() ; clazz != Object.class ; clazz = clazz.getSuperclass()) {
try {
method = clazz.getDeclaredMethod(methodName, parameterTypes) ;
return method ;
} catch (Exception e) {
}
}
return null;
}
调用就不说了,需要判断一下,
if( return null){
//没有这个方法
}
|