Here you can find the source of invoke(String methodName, Object object, Class>[] argTypes, Object[] args)
public static Object invoke(String methodName, Object object, Class<?>[] argTypes, Object[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
//package com.java2s; /******************************************************************************* * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version.// w w w. j a v a 2 s.com * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * *******************************************************************************/ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static Object invoke(String methodName, Object object, Class<?>[] argTypes, Object[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Method method = object.getClass().getDeclaredMethod(methodName, argTypes); method.setAccessible(true); return method.invoke(object, args); } }