Here you can find the source of invoke(Object obj, String methodName, Class[] parameterTypes, Object[] args)
public static Object invoke(Object obj, String methodName, Class[] parameterTypes, Object[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
//package com.java2s; //License from project: Apache License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static final Class[] EMPTY_CLASSES = new Class[0]; public static final Object[] EMPTY_PARAMS = EMPTY_CLASSES; public static Object invoke(Object obj, String methodName, Class[] parameterTypes, Object[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (parameterTypes == null) parameterTypes = EMPTY_CLASSES; Method method = obj.getClass().getMethod(methodName, parameterTypes); if (args == null) args = EMPTY_PARAMS;//from w ww .j av a2s . c o m return method.invoke(obj, args); } }