方法有很多种。例如,在getDeclaredMethod中,调用了privateGetDeclaredMethods;而privateGetDeclaredMethods调用了Reflection.filterMethods;
Reflection.filterMethods的实现如下:
- public static Method[] filterMethods(Class<?> containingClass, Method[] methods) {
- if (methodFilterMap == null) {
- return methods;
- }
- return (Method[])filter(methods, methodFilterMap.get(containingClass));
- }
复制代码 仅需对methodFilterMap做出修改,禁止getDeclaredMethod被get即可。
|