是覆盖方法
/** N o w J a v a . c o m 提 供 **/ /** * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main{ public static boolean isOverridenMethod(Class clazz, Method method, boolean checkThisClass) { try { if (checkThisClass) { clazz.getDeclaredMethod(method.getName(), method.getParameterTypes()); return true; } } catch (NoSuchMethodException e) { } // Check super class/*来自 N o w J a v a . c o m - 时 代 Java*/ if (clazz.getSuperclass() != null) { if (isOverridenMethod(clazz.getSuperclass(), method, true)) { return true; } } // Check interfaces for (Class anInterface : clazz.getInterfaces()) { if (isOverridenMethod(anInterface, method, true)) { return true; } } return false; } public static Class[] getParameterTypes(String... parameterTypeNames) { Class[] parameterTypes = new Class[parameterTypeNames.length]; for (int i = 0; i < parameterTypeNames.length; i++) { parameterTypes[i] = getClass(parameterTypeNames[i]); } return parameterTypes; } public