### Question:
ReflectionUtils { public static Method findMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) { Class<?> current = clazz; while (true) { try { return current.getDeclaredMethod(methodName, paramTypes); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { } if (current == Object.class) break; current = current.getSuperclass(); } return null; }  static List<Class<?>> getTypeArguments(Class<T> baseClass, Class<? extends T> childClass); static Method findMethod(Class<?> clazz, String methodName, Class<?>... paramTypes); static Field findField(Class<?> clazz, String fieldName); static List<Field> findFields(Class<?> clazz); static Method getMethod(Class<?> clazz, String methodName, Class<?>...paramTypes); static Object invokeStaticMethod(Class<?> clazz, String methodName, Object...params); static Object invokeMethod(Object object, String methodName, Object...params); static T instantiateClass(Class<T> clazz, Object... params); @SuppressWarnings("unchecked") static Constructor<T> findConstructor(Class<T> clazz, Class<?>... expectedParamTypes); static Class<?> getCollectionElementType(Type type); static Class<?> getMapKeyType(Type type); static Class<?> getMapValueType(Type type);  }### Answer:
@Test public void shouldFindMethodCorrectly() { Method method = ReflectionUtils.findMethod(SubClass4.class, "method", String.class, int.class); assertSame(method.getReturnType(), String.class); method = ReflectionUtils.findMethod(SuperClass1.class, "method", String.class, int.class); assertSame(method.getReturnType(), Object.class); method = ReflectionUtils.findMethod(SubClass4.class, "method2", String.class); assertSame(method.getParameterTypes()[0], String.class); method = ReflectionUtils.findMethod(SubClass4.class, "method2", Object.class); assertSame(method.getParameterTypes()[0], Object.class); }