public static Method findMethod(Class<?> type, String methodName) { try { return type.getDeclaredMethod(methodName); } catch (NoSuchMethodException e) { if (type.equals(Object.class) || type.isInterface()) { throw new CacheException(e); } return findMethod(type.getSuperclass(), methodName); } }
public static Method findMethod(Class<?> type, String methodName, Class<?>[] parameters) { try { return type.getDeclaredMethod(methodName, parameters); } catch (NoSuchMethodException e) { if (type.equals(Object.class) || type.isInterface()) { throw new CacheException(e); } return findMethod(type.getSuperclass(), methodName, parameters); } }