return invoke(method, target, new Object[0]);
}
public static Object invoke(Method method, Object target, Object[] args) {
if (method==null) {
throw new SquirrelRuntimeException(ErrorCodes.METHOD_NULL);
}
boolean oldAccessible = method.isAccessible();
try {
if (logger.isTraceEnabled()) {
logger.trace("invoking '"+method.getName()+"' on '"+target+"' with "+Arrays.toString(args));
}
if (!method.isAccessible()) {
logger.trace("making method accessible");
method.setAccessible(true);
}
return method.invoke(target, args);
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
throw new SquirrelRuntimeException(targetException, ErrorCodes.METHOD_INVOKE_ERROR,
method, Arrays.toString(args), target, targetException.getCause());
} catch (Exception e) {
throw new SquirrelRuntimeException(e, ErrorCodes.METHOD_INVOKE_ERROR,
method, Arrays.toString(args), target, e.getMessage());
} finally {
method.setAccessible(oldAccessible);
}
}