public static void invokeMethod ( Object target , Method method , Object ... arguments ) { method . setAccessible ( true ) ; // so we can call private and protected methods too try { method . invoke ( target , arguments ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Invoke the given method on the given target using the given arguments . Allows to call private and protected methods .