Java Reflection Method Invoke invokeMethod(Class clazz, String method, Class[] args, Object object, Object[] objects)

Here you can find the source of invokeMethod(Class clazz, String method, Class[] args, Object object, Object[] objects)

Description

invoke Method

License

Open Source License

Declaration

public static void invokeMethod(Class<?> clazz, String method, Class<?>[] args, Object object,
            Object[] objects) 

Method Source Code

//package com.java2s;
/**//from   w  w w  .  j a  va2 s .  c  om
 * 
 * This software is part of the MaterialAPI
 * 
 * This api allows plugin developers to create on a easy way custom
 * items with a custom id and recipes depending on them.
 * 
 * MaterialAPI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or 
 * any later version.
 *  
 * MaterialAPI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MaterialAPI. If not, see <http://www.gnu.org/licenses/>.
 * 
 */

import java.lang.reflect.Method;

public class Main {
    public static void invokeMethod(Class<?> clazz, String method, Class<?>[] args, Object object,
            Object[] objects) {
        try {
            Method m = clazz.getDeclaredMethod(method, args);
            m.setAccessible(true);
            m.invoke(object, objects);
        } catch (Exception ex) {
        }
    }
}

Related

  1. invokeMethod(Class clazz, Object obj, String methodName, Class[] parametersTypes, Object[] parameters)
  2. invokeMethod(Class clazz, String methodName, Object[] args)
  3. invokeMethod(Class targetClass, Object obj, String methodName, Object arg)
  4. invokeMethod(Class clazz, E instance, String[] names, Object... args)
  5. invokeMethod(Class clazz, Object object, String methodName, Class[] parameterTypes, Object[] parameters)
  6. invokeMethod(Class clz, String methodName, Object... params)
  7. invokeMethod(Class returnClass, String methodName, Object ivokeObject, Object... objects)
  8. invokeMethod(final Method method, final Object instance, final Object... args)
  9. invokeMethod(final Method method, final Object object)