Java Method Call invokeDeclaredMethod(String methodName, Object target, Class[] parameterTypes, Object[] parameters)

Here you can find the source of invokeDeclaredMethod(String methodName, Object target, Class[] parameterTypes, Object[] parameters)

Description

invoke Declared Method

License

Open Source License

Declaration

public static Object invokeDeclaredMethod(String methodName, Object target, Class[] parameterTypes,
            Object[] parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException 

Method Source Code

//package com.java2s;
/*/*from   w  w w.  ja  va 2 s.  co m*/
 * Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved.
 * ELEGA9T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved.
 */

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    public static Object invokeDeclaredMethod(String methodName, Object target, Class[] parameterTypes,
            Object[] parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Method method = target.getClass().getDeclaredMethod(methodName, parameterTypes);
        return invokeMethod(method, target, parameters);
    }

    public static Object invokeMethod(Method method, Object target, Object[] parameters)
            throws InvocationTargetException, IllegalAccessException {
        method.setAccessible(true);
        return method.invoke(target, parameters);
    }
}

Related

  1. invokeCallback(String callbackName, String callbackParam)
  2. invokeCmd(String className, String[] args)
  3. invokeDeclared(Class c, Object obj, String method, Class[] paramClasses, Object[] params)
  4. invokeDeclared(Class c, Object obj, String method, Class[] paramClasses, Object[] params)
  5. invokeDeclaredMethod(Object object, String methodName, Object... parameters)
  6. invokeDeclaredMethodWithAnnotation(Class annotationClass, Object target)
  7. invokeDefaultMethod(final Method method, final Object[] args, final Object proxy)
  8. invokedMethod(java.lang.Object closure, java.lang.Class targetClass, java.lang.String targetMethod)
  9. invokeExactField(Object object, String fieldName)