Method expressions can be "invoked". A javax.el.MethodExpression is invoked by calling its invoke(ELContext, Object<?>) method. The specification also allows to treat literal text as a method expression.
A method expression is called a literal method expression if its underlying expression is literal text (that is, isLiteralText() returns true). All other method expressions are called non-literal method expressions. Non-literal method expressions share the same syntax as lvalue expressions.
For literal method expressions
- invoke(ELContext, Object<?>) simply returns the expression string, optionally coerced to the expected return type specified at creation time.
- getMethodInfo(ELContext) always returns null.
On the other hand, non-literal method expressions refer to a java.lang.reflext.Method which can be invoked or used to create a javax.el.MethodInfo instance. For non-literal method expressions
- invoke(ELContext, Object<?>) evaluates the expression to a java.lang.reflext.Method and invokes that method, passing over the given actual parameters.
- the found method must match the expected return type (if it is not null) and the argument types given at creation time; otherwise an exception is thrown.