Here you can find the source of invoke(Method method, Object object, Object... parameters)
Parameter | Description |
---|---|
method | The method to invoke. |
object | The instance or class (for static methods) on which to invoke the method. |
parameters | The parameters to pass to the method. |
Parameter | Description |
---|---|
IOException | If I/O errors occur |
StripesRuntimeException | If anything else goes wrong |
@SuppressWarnings("unchecked") protected static <T> T invoke(Method method, Object object, Object... parameters) throws IOException, RuntimeException
//package com.java2s; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { /**//from w w w .ja v a2 s.c o m * Invoke a method on an object and return whatever it returns. * * @param method The method to invoke. * @param object The instance or class (for static methods) on which to invoke the method. * @param parameters The parameters to pass to the method. * @return Whatever the method returns. * @throws IOException If I/O errors occur * @throws StripesRuntimeException If anything else goes wrong */ @SuppressWarnings("unchecked") protected static <T> T invoke(Method method, Object object, Object... parameters) throws IOException, RuntimeException { try { return (T) method.invoke(object, parameters); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof IOException) throw (IOException) e.getTargetException(); else throw new RuntimeException(e); } } }