* the method expression to be wrapped
* @return a Method instance that when invoked causes the wrapped method expression to be invoked.
*/
public static Method methodExpressionToStaticMethod(final ELContext context, final MethodExpression methodExpression) {
MethodInfo methodInfo = methodExpression.getMethodInfo(getELContext());
try {
// Create a Method instance with the signature (return type, name, parameter types) corresponding
// to the method the MethodExpression references.
Constructor<Method> methodConstructor = Method.class.getDeclaredConstructor(Class.class,
String.class, Class[].class, Class.class,
Class[].class, int.class, int.class, String.class, byte[].class, byte[].class, byte[].class
);
methodConstructor.setAccessible(true);
Method staticMethod = methodConstructor.newInstance(null,
methodInfo.getName(), methodInfo.getParamTypes(), methodInfo.getReturnType(),
null, 0, 0, null, null, null, null
);
// The Sun/Oracle/OpenJDK Method makes use of a private delegator called MethodAccessor.
// Though specific to those JDKs, this is what we can use to let our Method instance execute something