Here you can find the source of invokeMethodWithKnownParamTypes(Object object, String methodName, Class[] methodParamTypes, Object... args)
public static Object invokeMethodWithKnownParamTypes(Object object, String methodName, Class[] methodParamTypes, Object... args)
//package com.java2s; //License from project: Apache License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static Object invokeMethodWithKnownParamTypes(Object object, String methodName, Class[] methodParamTypes, Object... args) {/*from www . j a v a2 s . c o m*/ Throwable t = null; try { Class clazz = object.getClass(); Method setter = clazz.getMethod(methodName, methodParamTypes); return setter.invoke(object, args); } catch (NoSuchMethodException e) { t = e; e.printStackTrace(); } catch (IllegalAccessException e) { t = e; e.printStackTrace(); } catch (InvocationTargetException e) { t = e; e.printStackTrace(); } throw new RuntimeException("Invoke failed", t); } }