public FEELFnResult<Object> invoke(EvaluationContext ctx, Object[] params) { if( params.length != parameters.size() ) { return FEELFnResult.ofError(new InvalidInputEvent(Severity.ERROR, "Illegal invocation of function", getName(), getName() + "( " + Arrays.asList(params)+" )", getSignature())); } FEELEvent capturedException = null; try { ctx.enterFrame(); for ( int i = 0; i < parameters.size(); i++ ) { ctx.setValue( parameters.get( i ), params[i] ); } Object[] actualParams = prepareParams( params ); Object result = method.invoke( clazz, actualParams ); return FEELFnResult.ofResult( result ); } catch ( InvocationTargetException e ) { String message = e.getTargetException().getMessage(); capturedException = new FEELEventBase(Severity.ERROR, "Error invoking "+toString()+": "+message, new RuntimeException("Error invoking function " + getSignature() + ".", e)); } catch ( IllegalAccessException e ) { String message = e.getCause().getMessage(); capturedException = new FEELEventBase(Severity.ERROR, "Error invoking "+toString()+": "+message, new RuntimeException("Error invoking function " + getSignature() + ".", e)); } finally { ctx.exitFrame(); } return FEELFnResult.ofError( capturedException ); }