@Test void invokeNoArgsVoid() throws NoSuchMethodException { TestClass mock = Mockito.mock(TestClass.class); Method method1 = mock.getClass().getDeclaredMethod("method1"); MethodUtil.invoke(method1, mock); Mockito.verify(mock, times(1)).method1(); }
public static Object invoke(Method method, Object target, Object... args) { try { method.setAccessible(true); return method.invoke(target, args); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }
MethodUtil extends UtilityClass { public static Object invoke(Method method, Object target, Object... args) { try { method.setAccessible(true); return method.invoke(target, args); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } } }
MethodUtil extends UtilityClass { public static Object invoke(Method method, Object target, Object... args) { try { method.setAccessible(true); return method.invoke(target, args); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }  }
MethodUtil extends UtilityClass { public static Object invoke(Method method, Object target, Object... args) { try { method.setAccessible(true); return method.invoke(target, args); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }  static Object invoke(Method method, Object target, Object... args); static Stream<A> annotations(Class<A> annotationClass, Method method); static Method fromReference(Function1<T,V> methodReference); static Method fromReference(FunctionInt<T> methodReference); static Method fromReference(FunctionOptional1<T,V> methodReference); static Class<?> referringClass(Function1<T,V> methodReference); static Class<?> referringClass(FunctionInt<T> methodReference); static Class<?> referringClass(FunctionOptional1<T,V> methodReference); }
MethodUtil extends UtilityClass { public static Object invoke(Method method, Object target, Object... args) { try { method.setAccessible(true); return method.invoke(target, args); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }  static Object invoke(Method method, Object target, Object... args); static Stream<A> annotations(Class<A> annotationClass, Method method); static Method fromReference(Function1<T,V> methodReference); static Method fromReference(FunctionInt<T> methodReference); static Method fromReference(FunctionOptional1<T,V> methodReference); static Class<?> referringClass(Function1<T,V> methodReference); static Class<?> referringClass(FunctionInt<T> methodReference); static Class<?> referringClass(FunctionOptional1<T,V> methodReference);  }