1 46 package org.codehaus.groovy.runtime; 47 48 import java.lang.reflect.Method ; 49 50 58 public class ReflectionMethodInvoker { 59 60 69 public static Object invoke(Object object, String methodName, Object [] parameters) { 70 try { 71 Class [] classTypes = new Class [parameters.length]; 72 for (int i = 0; i < classTypes.length; i++) { 73 classTypes[i] = parameters[i].getClass(); 74 } 75 Method method = object.getClass().getMethod(methodName, classTypes); 76 return method.invoke(object, parameters); 77 } catch (Throwable t) { 78 return InvokerHelper.invokeMethod(object, methodName, parameters); 79 } 80 } 81 82 } 83 | Popular Tags |