Here you can find the source of invoke(Object target, String methodName, Object... args)
public static <E> E invoke(Object target, String methodName, Object... args)
//package com.java2s; //License from project: LGPL import java.lang.reflect.Method; public class Main { public static <E> E invoke(Object target, String methodName, Object... args) { for (Method method : target.getClass().getMethods()) { if (method.getName().equals(methodName)) { try { return (E) method.invoke(target, args); } catch (Exception e) { throw new RuntimeException("Exception invoking method " + methodName, e); }//from w w w. ja v a2s. c o m } } throw new RuntimeException("Method " + methodName + " not found"); } }