1. el-spec
  2. EL_SPEC-11

Clarify how single variable evaluates to method


    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Labels:


      Section in the EL specification mentions that a method expression can consist of a single variable:

      A method expression shares the same syntax as an lvalue. 
      That is, it can only consist of either a single variable
      (e.g. ${name}) or a property resolution on some object, 
      via the . or [] operator (e.g. ${employee.name}).

      As it appears, it's not entirely clear how such single variable should be evaluated.

      In the reference implementation for example, we see that in this case a MethodExpressionImpl will reference an AstIdentifier, which will use the context's variable mapper to obtain a ValueExpression. The value is then obtained from this value expression, and it's expected to be a MethodExpression, which is then invoked.

      This can be seen at http://java.net/projects/el-spec/sources/source-code/content/trunk/impl/src/main/java/com/sun/el/parser/AstIdentifier.java?rev=198 where the method getMethodExpression at line 198 demonstrates the "value expression wrapping a method expression" assumption. invoke at line 183 then shows this obtained method expression is simply invoked.

      Comments on line 198 and 209 explicitly mention 2 cases:

      case A: ValueExpression exists, getValue which must
      be a MethodExpression


      case B: evaluate the identity against the ELResolver, again, must be
      a MethodExpression to be able to invoke

      These cases however are not outlined in the specification. As a result, alternative EL implementations (like JUEL) have taken a completely different approach. In the case of JUEL, it also expects a ValueExpression, but then guessed that this value expression should be wrapping a Method. This on its turn leads to unexpected behavior and bugs such as reported here: http://code.google.com/p/omnifaces/issues/detail?id=100

      In order to ensure portability between EL implementations, I would like to request this specific case to be clarified in the specification.



          • Assignee:
            arjan tijms
          • Votes:
            2 Vote for this issue
            1 Start watching this issue


            • Created: