Here you can find the source of invoke(final Object target, final Method method, final Object... parameters)
Parameter | Description |
---|---|
target | Target class that contains method. |
method | Method to invoke on target. |
parameters | Method parameters. |
public static Object invoke(final Object target, final Method method, final Object... parameters)
//package com.java2s; /* See LICENSE for licensing and NOTICE for copyright. */ import java.lang.reflect.Method; public class Main { /**//w ww . j a v a 2 s . c o m * Invokes the method on the target object with the given parameters. * * @param target Target class that contains method. * @param method Method to invoke on target. * @param parameters Method parameters. * * @return Method return value. A void method returns null. */ public static Object invoke(final Object target, final Method method, final Object... parameters) { try { return method.invoke(target, parameters); } catch (Exception e) { throw new RuntimeException("Failed invoking " + method, e); } } }