Here you can find the source of invoke(Object o, String m, Object... params)
public static Object invoke(Object o, String m, Object... params)
//package com.java2s; // This software is distributed under the following license: import java.lang.reflect.*; public class Main { public static Object invoke(Object o, String m, Object... params) { return invoke(o.getClass(), o, m, params); }// w w w .j av a2s. c o m public static Object invoke(Class<?> c, Object o, String m, Object... params) { if (c == null) { return null; } Method methods[] = c.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(m)) { try { methods[i].setAccessible(true); return methods[i].invoke(o, params); } catch (Exception e) { } } } return invoke(c.getSuperclass(), o, m, params); } }