[ 
https://issues.apache.org/jira/browse/JEXL-304?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marcus Warm updated JEXL-304:
-----------------------------
    Description: 
I'm a user and committer of the JXLS framework. It uses JEXL to evaluate 
expressions. Since JEXL 3 it's not possible to evaluate "overview.limit.var". 
It was possible in V2. In our context "var" means "Value At Risk". I know "var" 
is a reserved word in JEXL. But in this "dotted-variables" context I think JEXL 
should try to use it as a variable, because it makes no sense as a var (=define 
variable) command.

 
{code:java}
public void testVar() {
  JexlEngine jexlEngine = new JexlBuilder().strict(false).create();
  JexlExpression jexlExpresssion =
      jexlEngine.createExpression("overview.limit.var");

  HashMap map3 = new HashMap();
  map3.put("var", "4711");
  HashMap map2 = new HashMap();
  map2.put("limit", map3);
  HashMap map = new HashMap();
  map.put("overview", map2);

  MapContext context = new MapContext(map);
  Object value = jexlExpresssion.evaluate(context);
  assertEquals("4711", value); // fails
}
{code}
Error message:
{code:java}
org.apache.commons.jexl3.JexlException$Parsing: 
de.xmap.tools.jexl.JEXL3VariableTest.testVar@1:15 parsing error in '.'
  at org.apache.commons.jexl3.JexlEngine.createExpression(JexlEngine.java:304)
  at de.xmap.tools.jexl.JEXL3VariableTest.testVar(JEXL3VariableTest.java:107)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method){code}

  was:
I'm a user and committer of the JXLS framework. It uses JEXL to evaluate 
expressions. Since JEXL 3 it's not possible to evaluate "overview.limit.var". 
It was possible in V2. In our context "var" means "Value At Risk". I know "var" 
is a reserved word in JEXL. But in this "dotted-variables" context I think JEXL 
should try to use it as a variable, because it makes no sense as a var (=define 
variable) command.

 
{code:java}
public void testVar() {
  JexlEngine jexlEngine = new JexlBuilder().strict(false).create();
  JexlExpression jexlExpresssion =
      jexlEngine.createExpression("overview.limit.var");

  HashMap map3 = new HashMap();
  map3.put("var", "4711");
  HashMap map2 = new HashMap();
  map2.put("limit", map3);
  HashMap map = new HashMap();
  map.put("overview", map2);

  MapContext context = new MapContext(map);
  Object value = jexlExpresssion.evaluate(context);
  assertEquals("4711", value); // fails
}
{code}


> Error parsing overview.limit.var
> --------------------------------
>
>                 Key: JEXL-304
>                 URL: https://issues.apache.org/jira/browse/JEXL-304
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.1
>            Reporter: Marcus Warm
>            Priority: Minor
>
> I'm a user and committer of the JXLS framework. It uses JEXL to evaluate 
> expressions. Since JEXL 3 it's not possible to evaluate "overview.limit.var". 
> It was possible in V2. In our context "var" means "Value At Risk". I know 
> "var" is a reserved word in JEXL. But in this "dotted-variables" context I 
> think JEXL should try to use it as a variable, because it makes no sense as a 
> var (=define variable) command.
>  
> {code:java}
> public void testVar() {
>   JexlEngine jexlEngine = new JexlBuilder().strict(false).create();
>   JexlExpression jexlExpresssion =
>       jexlEngine.createExpression("overview.limit.var");
>   HashMap map3 = new HashMap();
>   map3.put("var", "4711");
>   HashMap map2 = new HashMap();
>   map2.put("limit", map3);
>   HashMap map = new HashMap();
>   map.put("overview", map2);
>   MapContext context = new MapContext(map);
>   Object value = jexlExpresssion.evaluate(context);
>   assertEquals("4711", value); // fails
> }
> {code}
> Error message:
> {code:java}
> org.apache.commons.jexl3.JexlException$Parsing: 
> de.xmap.tools.jexl.JEXL3VariableTest.testVar@1:15 parsing error in '.'
>   at org.apache.commons.jexl3.JexlEngine.createExpression(JexlEngine.java:304)
>   at de.xmap.tools.jexl.JEXL3VariableTest.testVar(JEXL3VariableTest.java:107)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method){code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to