Skip to content

Instantly share code, notes, and snippets.

@hferentschik
Created January 22, 2013 10:26
Show Gist options
  • Save hferentschik/4593620 to your computer and use it in GitHub Desktop.
Save hferentschik/4593620 to your computer and use it in GitHub Desktop.
private Object invokeMethod(Method m, Object base, Object[] params) {
Class[] parameterTypes = m.getParameterTypes();
Object[] parameters = null;
if (parameterTypes.length > 0) {
ExpressionFactory exprFactory = ExpressionFactory.newInstance();
if (m.isVarArgs()) {
// TODO
} else {
parameters = new Object[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++) {
parameters[i] = exprFactory.coerceToType(params[i],
parameterTypes[i]);
}
}
}
try {
return m.invoke(base, parameters);
} catch (IllegalAccessException iae) {
throw new ELException(iae);
} catch (InvocationTargetException ite) {
throw new ELException(ite.getCause());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment