Here you can find the source of invoke(Object object, String methodName, Class>[] argTypes, Object... args)
public static Object invoke(Object object, String methodName, Class<?>[] argTypes, Object... args)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static Object invoke(Object object, String methodName, Class<?>[] argTypes, Object... args) { try {//from ww w . j a v a 2 s . c o m Method onLayout = object.getClass().getDeclaredMethod(methodName, argTypes); onLayout.setAccessible(true); return onLayout.invoke(object, args); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } } }