Here you can find the source of invokeMethod(Method method, Object target, Object... arguments)
public static Object invokeMethod(Method method, Object target, Object... arguments) throws InvocationTargetException
//package com.java2s; //License from project: Apache License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static Object invokeMethod(Method method, Object target, Object... arguments) throws InvocationTargetException { if (!method.isAccessible()) { method.setAccessible(true);//from w w w.j a va2 s . c o m } try { return method.invoke(target, arguments); } catch (IllegalAccessException ex) { throw new RuntimeException("", ex); } } }