Here you can find the source of invokeDeclaredMethod(String methodName, Object target, Class[] parameterTypes, Object[] parameters)
public static Object invokeDeclaredMethod(String methodName, Object target, Class[] parameterTypes, Object[] parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
//package com.java2s; /*/*from w w w. ja va 2 s. co m*/ * Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved. * ELEGA9T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved. */ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static Object invokeDeclaredMethod(String methodName, Object target, Class[] parameterTypes, Object[] parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method method = target.getClass().getDeclaredMethod(methodName, parameterTypes); return invokeMethod(method, target, parameters); } public static Object invokeMethod(Method method, Object target, Object[] parameters) throws InvocationTargetException, IllegalAccessException { method.setAccessible(true); return method.invoke(target, parameters); } }