/**循環(huán)向上轉(zhuǎn)型,獲取對象的的DeclaredMethod * @param object * @param methodname * @param parameterTypes * @return */ public static Method getDeclaredMethod(Object object, String methodname, Class<?>[] parameterTypes){ for (Class<?> superClass = object.getClass(); superClass != Object.class;? superClass = superClass.getSuperclass()) { try { // return superClass.getDeclaredMethod(methodname, parameterTypes); } catch (NoSuchMethodException e) { //method 不在當(dāng)前類定義,繼續(xù)向上轉(zhuǎn)型 } } return null; }
添加回答
舉報
0/150
提交
取消