jsr341-experts@el-spec.java.net

[jsr341-experts] A clarification to assignment operator

From: Kin-man Chung <kinman.chung_at_oracle.com>
Date: Mon, 12 Sep 2011 15:51:12 -0700

While working on implementing the assignment operator, I noticed an
ambiguity in assignmet to an EL variable. Consider the following.

   elp = new ELProcessor();
   elp.defineBean("x", "something"); // bean x has the value "something"
   elp.setVariable("y", "x"); // variable y is set to #{x}
   elp.getValue("y = 100"); // assign 100 to y

What is the value of x and y after the assignment?

There are 2 possible answers to this question.
1. 100, and 100, since y is #{x}, #{y=100} is rewritten as #{x = 100}
2. 100, and "something", since only x is assigned the new value.

The current spec does not specify the behavior of calling setValue on
the expression #{y} when y is a variable, and the currently
implementation would result in 1, since it just substitute a variable
with its set value in expression evaluations.

But I think 2 makes more sense since that would produce the same
behavior for the follow two statements:

   elp.getValue("y = 100"); and
   elp.setVariable("y", "100");

I have edit the wiki http://java.net/projects/el-spec/pages/Operators to
indicate 2 explicitly. If you have issues with this, please let me know.

Kin-man