Here you can find the source of invokeMethod(Object cls, String methodName, Class> paramClass, String paramValue)
private static void invokeMethod(Object cls, String methodName, Class<?> paramClass, String paramValue) throws Exception
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; public class Main { private static void invokeMethod(Object cls, String methodName, Class<?> paramClass, String paramValue) throws Exception { try {// w w w . ja va2s . c o m Method method = cls.getClass().getMethod(methodName, new Class[] { paramClass }); method.invoke(cls, new Object[] { paramValue }); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } throw e; } } }