Here you can find the source of invokeMethod(Object owner, String methodName)
public static Object invokeMethod(Object owner, String methodName) throws Exception
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { public static Object invokeMethod(Object owner, String methodName) throws Exception { return invokeMethod(owner, methodName, new Object[] {}); }// w w w .j av a 2 s .com public static Object invokeMethod(Object owner, String methodName, Object... args) throws Exception { Class<?> ownerClass = owner.getClass(); int argsNum = 0; Class<?>[] argsClass; if (args == null) { argsClass = new Class[0]; } else { argsNum = args.length; argsClass = new Class[argsNum]; } for (int i = 0, j = argsNum; i < j; i++) { argsClass[i] = args[i].getClass(); } Method method = ownerClass.getMethod(methodName, argsClass); return method.invoke(owner, args); } }