Issue Details (XML | Word | Printable)

Key: EL_SPEC-11
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: arjan tijms
Votes: 2
Watchers: 1

If you were logged in you would be able to see more operations.

Clarify how single variable evaluates to method

Created: 08/Jan/13 06:36 PM   Updated: 19/Mar/13 05:45 PM   Resolved: 19/Mar/13 05:36 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Tags: methodexpression evaluation clarification
Participants: arjan tijms, beckchr and kchung

 Description  « Hide

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. ${}).

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 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:

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

arjan tijms added a comment - 19/Mar/13 05:45 PM

What about adding the following clarification to [...]

It sounds okay to me, thanks!

kchung added a comment - 19/Mar/13 05:36 PM

Added a new section 1.5.4. in EL 3.0 spec to clarify the issue.

kchung added a comment - 19/Mar/13 06:12 AM

What about adding the following clarification to

When a MethodExpression created from an EL expression of the form ${name} is invoked,

1. The identifier "name" is first evaluated.
a. If "name" is an EL variable, the ValueExpression associated with the variable is evaluated.
b. Else obtain the value resolved in the ELResolvers.
2. If the identifier evaluates to a MethodExpression, it is invoked and its result is returned.
3. Else error.

beckchr added a comment - 08/Jan/13 07:35 PM - edited

See also this issue from 2006: