[jira] [Created] (JEXL-428) Make Comparable object high priority while comparing

2024-09-04 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-428:
-

 Summary: Make Comparable object high priority while comparing
 Key: JEXL-428
 URL: https://issues.apache.org/jira/browse/JEXL-428
 Project: Commons JEXL
  Issue Type: Improvement
Reporter: Xu Pengcheng


[https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java#L787]

 

I defined a Class with implemented Comparable interface, when compare it with a 
string object, engine does not call the compareTo method but compares by string 
value.

 

At JexlArithmetic.java L787, if one of the left/right value is string type, 
then compares by string value, I think if the left value is Comparable and not 
String type, using left object's compareTo method first makes more sense.

Thanks!

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-427) Support &: operator

2024-08-29 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17877681#comment-17877681
 ] 

Xu Pengcheng commented on JEXL-427:
---

Thanks!

but this actually changed the current behavior (return false/true), is it 
better to add a flag too? 

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-425) Multiline format literals does not always return string.

2024-08-29 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17877680#comment-17877680
 ] 

Xu Pengcheng commented on JEXL-425:
---

Great, thank you very much!

> Multiline format literals does not always return string.
> 
>
> Key: JEXL-425
> URL: https://issues.apache.org/jira/browse/JEXL-425
> Project: Commons JEXL
>  Issue Type: Bug
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> For example
>  
> {code:java}
> let x = 10;
> let y = `${x}` // y is integer type of 10, expect y to be string
> let z = `${x}1` // z is string '101'{code}
>  
> here the type of `y` expected to be string.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-426) Value of Captured Variable

2024-08-29 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17877679#comment-17877679
 ] 

Xu Pengcheng commented on JEXL-426:
---

Great, thank you very much!

> Value of Captured Variable 
> ---
>
> Key: JEXL-426
> URL: https://issues.apache.org/jira/browse/JEXL-426
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> For the code
> {code:java}
> let x = 10;
> function foo() {
>   x += 2;
> }
> foo();
> return x;{code}
> By default the return value of x is 10 because `x` inside `foo` is a captured 
> value, re-assign value not affect the variable outside `foo`, which some 
> times confuse the developer, therefore a new feature `constCapture` was 
> introduced to prevent such kind of re-assignment, which is the same behavior 
> of Java code.
> But the problem is variable `x` outside of function is not const, for the 
> following code
>  
> {code:java}
> 1:  let x = 10;
> 2:  function foo() {
> 3:someCall(x);
> 4:  }
> 5:  x = 20;
> 6:  foo();
> 7:  return x; {code}
> This code is valid with constCapture = true (similar code in java is invalid 
> because x needs to be 'final'), but the value inside `foo` is 10, not 20, I 
> checked the JEXL source codes and found the value inside `foo` is captured 
> when defining `foo` function (line 3), which is 10, even when calling `foo` 
> in line 6 the value of x is already be 20, this case is also somehow confuse.
>  
> I tried extending Interpreter to change the behavior of captured variable to:
>  # re-assign the captured variable to latest value from parent frame before 
> executing.
>  # populate the value to parent scope while assigning new value to a captured 
> variable
> with this interpreter, the value of x in line 3 and 7 are 22, which I think 
> is more easy to understand.
> {code:java}
> 1:  let x = 10;
> 2:  function foo() {
> 3:x += 2; // here x = 22
> 4:  }
> 5:  x = 20;
> 6:  foo();
> 7:  return x; // here x = 22{code}
>  
> Is it possible to add a new feature to support this behavior?
> or provide more apis, i.e.
>  # api to get whole frame stack (now I store it in JexlContext)
>  # read/write value by variable name for a frame (now I reflect the 
> get/set/getSymbol methods of Frame class)
>  # get parent of Scope.
> Thanks very much!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-427) Support &: operator

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876785#comment-17876785
 ] 

Xu Pengcheng commented on JEXL-427:
---

+1

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (JEXL-427) Support &: operator

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876765#comment-17876765
 ] 

Xu Pengcheng edited comment on JEXL-427 at 8/26/24 4:39 PM:


The reason we do so is to reuse the existing JS/TS tools, including code 
editor, language server (we use typescript-language-server but redefined apis) 
AI support (chatgpt can write good js code but not so good at jexl). And we had 
already implemented some libs (i.e. Math, Date, Regex, etc) and polyfill the 
difference between Jexl and JS (JEXL-426 is also for this).

And the reason why we don't choose real JS VM is because Jexl is much faster 
and lightweight, supports accessing/operating object directly, has better 
permission/timeout control and has more extensibility.

Frankly speaking, I hope Jexl supports more JS syntax, which makes more easily 
to reuse the existing wheels, and open more apis is also helpful (i.e. the apis 
to access data of frame, as I mentioned in JEXL-426).

Thanks!


was (Author: JIRAUSER294041):
The reason we do so is to reuse the existing JS/TS tools, including code 
editor, language server (we use typescript-language-server but redefined apis) 
AI support (chatgpt can write good js code but not so good at jexl). And we had 
already implemented some libs (i.e. Math, Date, Regex, etc) and polyfill the 
difference between Jexl and JS (JEXL-426 is also for this).

And the reason why we don't choose real JS VM is because Jexl is much faster 
and lightweight, supports accessing/operating object directly, has better 
permission/timeout control and has more extensibility.

Frankly speaking, I hope Jexl supports more JS syntax, which makes more easily 
to reuse the existing wheels, and open more apis (i.e. the apis to access data 
of frame, as I mentioned in JEXL-426).

Thanks!

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (JEXL-427) Support &: operator

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876765#comment-17876765
 ] 

Xu Pengcheng edited comment on JEXL-427 at 8/26/24 4:11 PM:


The reason we do so is to reuse the existing JS/TS tools, including code 
editor, language server (we use typescript-language-server but redefined apis) 
AI support (chatgpt can write good js code but not so good at jexl). And we had 
already implemented some libs (i.e. Math, Date, Regex, etc) and polyfill the 
difference between Jexl and JS (JEXL-426 is also for this).

And the reason why we don't choose real JS VM is because Jexl is much faster 
and lightweight, supports accessing/operating object directly, has better 
permission/timeout control and has more extensibility.

Frankly speaking, I hope Jexl supports more JS syntax, which makes more easily 
to reuse the existing wheels, and open more apis (i.e. the apis to access data 
of frame, as I mentioned in JEXL-426).

Thanks!


was (Author: JIRAUSER294041):
The reason we do so is to reuse the existing JS/TS tools, including code 
editor, language server (we use typescript-language-server but redefined apis) 
AI support (chatgpt can write good js code but not so good at jexl). And we had 
alreadyLibrary implementation (i.e. Math, Date, Regex, etc) and polyfill the 
difference between Jexl and JS (JEXL-426 is also for this).

And the reason why we don't choose real JS VM is because Jexl is much faster 
and lightweight, supports accessing/operating object directly, has better 
permission/timeout control and has more extensibility.

Frankly speaking, I hope Jexl supports more JS syntax, which makes more easily 
to reuse the existing wheels, and open more apis (i.e. the apis to access data 
of frame, as I mentioned in JEXL-426).

Thanks!

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (JEXL-427) Support &: operator

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876765#comment-17876765
 ] 

Xu Pengcheng edited comment on JEXL-427 at 8/26/24 4:11 PM:


The reason we do so is to reuse the existing JS/TS tools, including code 
editor, language server (we use typescript-language-server but redefined apis) 
AI support (chatgpt can write good js code but not so good at jexl). And we had 
alreadyLibrary implementation (i.e. Math, Date, Regex, etc) and polyfill the 
difference between Jexl and JS (JEXL-426 is also for this).

And the reason why we don't choose real JS VM is because Jexl is much faster 
and lightweight, supports accessing/operating object directly, has better 
permission/timeout control and has more extensibility.

Frankly speaking, I hope Jexl supports more JS syntax, which makes more easily 
to reuse the existing wheels, and open more apis (i.e. the apis to access data 
of frame, as I mentioned in JEXL-426).

Thanks!


was (Author: JIRAUSER294041):
The reason we do so is to reuse the existing JS/TS tools, including code 
editor, language server (we use typescript-language-server but redefined apis), 
AI support (chatgpt can write good js code but not so good at jexl), Library 
implementation (i.e. Math, Date, Regex, etc) and polyfill the difference 
between Jexl and JS (JEXL-426 is also for this).

And the reason why we don't choose real JS VM is because Jexl is much faster 
and lightweight, supports accessing/operating object directly, has better 
permission/timeout control and has more extensibility.

Frankly speaking, I hope Jexl supports more JS syntax, which makes more easily 
to reuse the existing wheels, and open more apis (i.e. the apis to access data 
of frame, as I mentioned in JEXL-426).

Thanks!

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-425) Multiline format literals does not always return string.

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876771#comment-17876771
 ] 

Xu Pengcheng commented on JEXL-425:
---

got it, a flag is fine, thanks for your explaination!

> Multiline format literals does not always return string.
> 
>
> Key: JEXL-425
> URL: https://issues.apache.org/jira/browse/JEXL-425
> Project: Commons JEXL
>  Issue Type: Bug
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> For example
>  
> {code:java}
> let x = 10;
> let y = `${x}` // y is integer type of 10, expect y to be string
> let z = `${x}1` // z is string '101'{code}
>  
> here the type of `y` expected to be string.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-426) Value of Captured Variable

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876769#comment-17876769
 ] 

Xu Pengcheng commented on JEXL-426:
---

const is better than current one.

But if the value can be synced between captured value and its source, is much 
better.

> Value of Captured Variable 
> ---
>
> Key: JEXL-426
> URL: https://issues.apache.org/jira/browse/JEXL-426
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> For the code
> {code:java}
> let x = 10;
> function foo() {
>   x += 2;
> }
> foo();
> return x;{code}
> By default the return value of x is 10 because `x` inside `foo` is a captured 
> value, re-assign value not affect the variable outside `foo`, which some 
> times confuse the developer, therefore a new feature `constCapture` was 
> introduced to prevent such kind of re-assignment, which is the same behavior 
> of Java code.
> But the problem is variable `x` outside of function is not const, for the 
> following code
>  
> {code:java}
> 1:  let x = 10;
> 2:  function foo() {
> 3:someCall(x);
> 4:  }
> 5:  x = 20;
> 6:  foo();
> 7:  return x; {code}
> This code is valid with constCapture = true (similar code in java is invalid 
> because x needs to be 'final'), but the value inside `foo` is 10, not 20, I 
> checked the JEXL source codes and found the value inside `foo` is captured 
> when defining `foo` function (line 3), which is 10, even when calling `foo` 
> in line 6 the value of x is already be 20, this case is also somehow confuse.
>  
> I tried extending Interpreter to change the behavior of captured variable to:
>  # re-assign the captured variable to latest value from parent frame before 
> executing.
>  # populate the value to parent scope while assigning new value to a captured 
> variable
> with this interpreter, the value of x in line 3 and 7 are 22, which I think 
> is more easy to understand.
> {code:java}
> 1:  let x = 10;
> 2:  function foo() {
> 3:x += 2; // here x = 22
> 4:  }
> 5:  x = 20;
> 6:  foo();
> 7:  return x; // here x = 22{code}
>  
> Is it possible to add a new feature to support this behavior?
> or provide more apis, i.e.
>  # api to get whole frame stack (now I store it in JexlContext)
>  # read/write value by variable name for a frame (now I reflect the 
> get/set/getSymbol methods of Frame class)
>  # get parent of Scope.
> Thanks very much!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-427) Support &: operator

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876767#comment-17876767
 ] 

Xu Pengcheng commented on JEXL-427:
---

from the syntax doc, '&&'/'||' can not be overloaded and I checked arithmetic 
code, and()/or() is bitwise {{and/or.}}

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-427) Support &: operator

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876765#comment-17876765
 ] 

Xu Pengcheng commented on JEXL-427:
---

The reason we do so is to reuse the existing JS/TS tools, including code 
editor, language server (we use typescript-language-server but redefined apis), 
AI support (chatgpt can write good js code but not so good at jexl), Library 
implementation (i.e. Math, Date, Regex, etc) and polyfill the difference 
between Jexl and JS (JEXL-426 is also for this).

And the reason why we don't choose real JS VM is because Jexl is much faster 
and lightweight, supports accessing/operating object directly, has better 
permission/timeout control and has more extensibility.

Frankly speaking, I hope Jexl supports more JS syntax, which makes more easily 
to reuse the existing wheels, and open more apis (i.e. the apis to access data 
of frame, as I mentioned in JEXL-426).

Thanks!

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-426) Value of Captured Variable

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876757#comment-17876757
 ] 

Xu Pengcheng commented on JEXL-426:
---

The problem is that the rule of "should not be altered" will not trigger any 
error, in your test case, if line 5 is 
 
x = [40]
 
there is no error and the result is 40, it is not a good practice, but once it 
happens, it is very hard to debug and explain why.
 

> Value of Captured Variable 
> ---
>
> Key: JEXL-426
> URL: https://issues.apache.org/jira/browse/JEXL-426
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> For the code
> {code:java}
> let x = 10;
> function foo() {
>   x += 2;
> }
> foo();
> return x;{code}
> By default the return value of x is 10 because `x` inside `foo` is a captured 
> value, re-assign value not affect the variable outside `foo`, which some 
> times confuse the developer, therefore a new feature `constCapture` was 
> introduced to prevent such kind of re-assignment, which is the same behavior 
> of Java code.
> But the problem is variable `x` outside of function is not const, for the 
> following code
>  
> {code:java}
> 1:  let x = 10;
> 2:  function foo() {
> 3:someCall(x);
> 4:  }
> 5:  x = 20;
> 6:  foo();
> 7:  return x; {code}
> This code is valid with constCapture = true (similar code in java is invalid 
> because x needs to be 'final'), but the value inside `foo` is 10, not 20, I 
> checked the JEXL source codes and found the value inside `foo` is captured 
> when defining `foo` function (line 3), which is 10, even when calling `foo` 
> in line 6 the value of x is already be 20, this case is also somehow confuse.
>  
> I tried extending Interpreter to change the behavior of captured variable to:
>  # re-assign the captured variable to latest value from parent frame before 
> executing.
>  # populate the value to parent scope while assigning new value to a captured 
> variable
> with this interpreter, the value of x in line 3 and 7 are 22, which I think 
> is more easy to understand.
> {code:java}
> 1:  let x = 10;
> 2:  function foo() {
> 3:x += 2; // here x = 22
> 4:  }
> 5:  x = 20;
> 6:  foo();
> 7:  return x; // here x = 22{code}
>  
> Is it possible to add a new feature to support this behavior?
> or provide more apis, i.e.
>  # api to get whole frame stack (now I store it in JexlContext)
>  # read/write value by variable name for a frame (now I reflect the 
> get/set/getSymbol methods of Frame class)
>  # get parent of Scope.
> Thanks very much!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-427) Support &: operator

2024-08-26 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876754#comment-17876754
 ] 

Xu Pengcheng commented on JEXL-427:
---

I am working with a JS to jexl code converter, in JS '||' equals Jexl '?:', but 
there is no '&&' equivalent operator.

Thanks!

> Support &: operator
> ---
>
> Key: JEXL-427
> URL: https://issues.apache.org/jira/browse/JEXL-427
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
>
> Similiar with ternary conditional `?:`, but
> {code:javascript}
> x &: y
> {code}
> equals
> {code:javascript}
> x ? y : x
> {code}
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-427) Support &: operator

2024-08-25 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-427:
-

 Summary: Support &: operator
 Key: JEXL-427
 URL: https://issues.apache.org/jira/browse/JEXL-427
 Project: Commons JEXL
  Issue Type: New Feature
Reporter: Xu Pengcheng


Similiar with ternary conditional `?:`, but

{code:javascript}
x &: y
{code}


equals

{code:javascript}
x ? y : x
{code}

Thanks!




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-426) Value of Captured Variable

2024-08-23 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-426:
-

 Summary: Value of Captured Variable 
 Key: JEXL-426
 URL: https://issues.apache.org/jira/browse/JEXL-426
 Project: Commons JEXL
  Issue Type: Improvement
Reporter: Xu Pengcheng


For the code
{code:java}
let x = 10;
function foo() {
  x += 2;
}
foo();
return x;{code}
By default the return value of x is 10 because `x` inside `foo` is a captured 
value, re-assign value not affect the variable outside `foo`, which some times 
confuse the developer, therefore a new feature `constCapture` was introduced to 
prevent such kind of re-assignment, which is the same behavior of Java code.

But the problem is variable `x` outside of function is not const, for the 
following code

 
{code:java}
1:  let x = 10;
2:  function foo() {
3:someCall(x);
4:  }
5:  x = 20;
6:  foo();
7:  return x; {code}
This code is valid with constCapture = true (similar code in java is invalid 
because x needs to be 'final'), but the value inside `foo` is 10, not 20, I 
checked the JEXL source codes and found the value inside `foo` is captured when 
defining `foo` function (line 3), which is 10, even when calling `foo` in line 
6 the value of x is already be 20, this case is also somehow confuse.

 

I tried extending Interpreter to change the behavior of captured variable to:
 # re-assign the captured variable to latest value from parent frame before 
executing.
 # populate the value to parent scope while assigning new value to a captured 
variable

with this interpreter, the value of x in line 3 and 7 are 22, which I think is 
more easy to understand.
{code:java}
1:  let x = 10;
2:  function foo() {
3:x += 2; // here x = 22
4:  }
5:  x = 20;
6:  foo();
7:  return x; // here x = 22{code}
 

Is it possible to add a new feature to support this behavior?

or provide more apis, i.e.
 # api to get whole frame stack (now I store it in JexlContext)
 # read/write value by variable name for a frame (now I reflect the 
get/set/getSymbol methods of Frame class)
 # get parent of Scope.

Thanks very much!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-425) Multiline format literals does not always return string.

2024-08-23 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-425:
-

 Summary: Multiline format literals does not always return string.
 Key: JEXL-425
 URL: https://issues.apache.org/jira/browse/JEXL-425
 Project: Commons JEXL
  Issue Type: Bug
Reporter: Xu Pengcheng


For example

 
{code:java}
let x = 10;
let y = `${x}` // y is integer type of 10, expect y to be string
let z = `${x}1` // z is string '101'{code}
 

here the type of `y` expected to be string.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-424) Permission error after upgraded to JDK 21

2024-06-14 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-424:
--
Description: 
{code:java}
JexlSandbox sandbox = new JexlSandbox(false, true);
sandbox.permissions(Map.class.getName(), true, true, true, true);
...
String jexlCode = "x.foo = 'bar';" 
JexlEngine engine =
new Engine(
new JexlBuilder()
.sandbox(sandbox)
.safe(false)
.strict(true));
Map vars = new LinkedHashMap<>();
vars.put("x",  new LinkedHashMap<>());
engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
The code is ok with JDK11, but caused an error "undefined property 'foo'" with 
JDK21.

 

I did some debug and found the problem is

JDK11:  LinkedHashMap implements Map

JDK21: LinkedHashMap implements SequencedMap extends Map

and from 
[JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
{code:java}
                for (final Class inter : clazz.getInterfaces()) {
                    permissions = sandbox.get(inter.getName());
                    if (permissions != null) {
                        if (permissions.isInheritable()) {
                            break;
                        }
                        permissions = null;
                    }
                } {code}
sandbox only checks the direct interfaces but not check it's super interface, 
but for class permission check, it looks into its parents, is it by design or a 
bug?

 

And also because which checking permission of class, it does not check it's 
interface's permission, the result of class is not stable in case parent class 
has permission from it's interface.

for example:
{code:java}
interface I{}
static class A implements I{}
static class B extends A{}

@Test
void testPermission() {
  JexlSandbox sandbox = new JexlSandbox(false, true);
  sandbox.permissions(I.class.getName(), true, true, true, false);
  System.out.println("permission A=" + sandbox.get(A.class.getName()).write());
  System.out.println("permission B=" + sandbox.get(B.class.getName()).write());
}
 {code}
result is 

permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
permission 
B=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13

but if checking B befoer A, the result is 

permission B=org.apache.commons.jexl3.introspection.JexlSandbox$2@6c1832aa
permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@47ad69f7

 

Maybe we need to travel the whole inheritance tree and also need a merge policy 
for multiple permission definitions?

 

BTW, what is the release date for next version? thanks!

 

  was:
{code:java}
JexlSandbox sandbox = new JexlSandbox(false, true);
sandbox.permissions(Map.class.getName(), true, true, true, true);
...
String jexlCode = "x.foo = 'bar';" 
JexlEngine engine =
new Engine(
new JexlBuilder()
.sandbox(sandbox)
.safe(false)
.strict(true));
Map vars = new LinkedHashMap<>();
vars.put("x",  new LinkedHashMap<>());
engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
The code is ok with JDK11, but caused an error "undefined property 'foo'" with 
JDK21.

 

I did some debug and found the problem is

JDK11:  LinkedHashMap implements Map

JDK21: LinkedHashMap implements SequencedMap extends Map

and from 
[JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
{code:java}
                for (final Class inter : clazz.getInterfaces()) {
                    permissions = sandbox.get(inter.getName());
                    if (permissions != null) {
                        if (permissions.isInheritable()) {
                            break;
                        }
                        permissions = null;
                    }
                } {code}
sandbox only checks the direct interfaces but not check it's super interface, 
but for class permission check, it looks into its parents, is it by design or a 
bug?

 

And also because which checking permission of class, it does not check it's 
interface's permission, the result of class is not stable in case parent class 
has permission from it's interface.

for example:
{code:java}
interface I{}
static class A implements I{}
static class B extends A{}

@Test
void testPermission() {
  JexlSandbox sandbox = new JexlSandbox(false, true);
  sandbox.permissions(I.class.getName(), true, true, true, false);
  System.out.println("permission A=" + sandbox.get(A.class.getName()).write());
  System.out.println("permission B=" + sandbox.get(B.class.getName()).write());
}
 {code}
result is 

permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
permission 
B=org.apache.commons.jexl3.introspection.JexlSandbox$Al

[jira] [Commented] (JEXL-424) Permission error after upgraded to JDK 21

2024-06-14 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17855020#comment-17855020
 ] 

Xu Pengcheng commented on JEXL-424:
---

got it, thank you!

> Permission error after upgraded to JDK 21
> -
>
> Key: JEXL-424
> URL: https://issues.apache.org/jira/browse/JEXL-424
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Priority: Major
>
> {code:java}
> JexlSandbox sandbox = new JexlSandbox(false, true);
> sandbox.permissions(Map.class.getName(), true, true, true, true);
> ...
> String jexlCode = "x.foo = 'bar';" 
> JexlEngine engine =
> new Engine(
> new JexlBuilder()
> .sandbox(sandbox)
> .safe(false)
> .strict(true));
> Map vars = new LinkedHashMap<>();
> vars.put("x",  new LinkedHashMap<>());
> engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
> The code is ok with JDK11, but caused an error "undefined property 'foo'" 
> with JDK21.
>  
> I did some debug and found the problem is
> JDK11:  LinkedHashMap implements Map
> JDK21: LinkedHashMap implements SequencedMap extends Map
> and from 
> [JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
> {code:java}
>                 for (final Class inter : clazz.getInterfaces()) {
>                     permissions = sandbox.get(inter.getName());
>                     if (permissions != null) {
>                         if (permissions.isInheritable()) {
>                             break;
>                         }
>                         permissions = null;
>                     }
>                 } {code}
> sandbox only checks the direct interfaces but not check it's super interface, 
> but for class permission check, it looks into its parents, is it by design or 
> a bug?
>  
> And also because which checking permission of class, it does not check it's 
> interface's permission, the result of class is not stable in case parent 
> class has permission from it's interface.
> for example:
> {code:java}
> interface I{}
> static class A implements I{}
> static class B extends A{}
> @Test
> void testPermission() {
>   JexlSandbox sandbox = new JexlSandbox(false, true);
>   sandbox.permissions(I.class.getName(), true, true, true, false);
>   System.out.println("permission A=" + 
> sandbox.get(A.class.getName()).write());
>   System.out.println("permission B=" + 
> sandbox.get(B.class.getName()).write());
> }
>  {code}
> result is 
> permission 
> A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
> permission 
> B=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
> but if checking B befoer A, the result is 
> permission B=org.apache.commons.jexl3.introspection.JexlSandbox$2@6c1832aa
> permission 
> A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@47ad69f7
>  
> BTW, what is the release date for next version? thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-424) Permission error after upgraded to JDK 21

2024-06-14 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-424:
--
Description: 
{code:java}
JexlSandbox sandbox = new JexlSandbox(false, true);
sandbox.permissions(Map.class.getName(), true, true, true, true);
...
String jexlCode = "x.foo = 'bar';" 
JexlEngine engine =
new Engine(
new JexlBuilder()
.sandbox(sandbox)
.safe(false)
.strict(true));
Map vars = new LinkedHashMap<>();
vars.put("x",  new LinkedHashMap<>());
engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
The code is ok with JDK11, but caused an error "undefined property 'foo'" with 
JDK21.

 

I did some debug and found the problem is

JDK11:  LinkedHashMap implements Map

JDK21: LinkedHashMap implements SequencedMap extends Map

and from 
[JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
{code:java}
                for (final Class inter : clazz.getInterfaces()) {
                    permissions = sandbox.get(inter.getName());
                    if (permissions != null) {
                        if (permissions.isInheritable()) {
                            break;
                        }
                        permissions = null;
                    }
                } {code}
sandbox only checks the direct interfaces but not check it's super interface, 
but for class permission check, it looks into its parents, is it by design or a 
bug?

 

And also because which checking permission of class, it does not check it's 
interface's permission, the result of class is not stable in case parent class 
has permission from it's interface.

for example:
{code:java}
interface I{}
static class A implements I{}
static class B extends A{}

@Test
void testPermission() {
  JexlSandbox sandbox = new JexlSandbox(false, true);
  sandbox.permissions(I.class.getName(), true, true, true, false);
  System.out.println("permission A=" + sandbox.get(A.class.getName()).write());
  System.out.println("permission B=" + sandbox.get(B.class.getName()).write());
}
 {code}
result is 

permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
permission 
B=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13

but if checking B befoer A, the result is 

permission B=org.apache.commons.jexl3.introspection.JexlSandbox$2@6c1832aa
permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@47ad69f7

 

BTW, what is the release date for next version? thanks!

 

  was:
{code:java}
JexlSandbox sandbox = new JexlSandbox(false, true);
sandbox.permissions(Map.class.getName(), true, true, true, true);
...
String jexlCode = "x.foo = 'bar';" 
JexlEngine engine =
new Engine(
new JexlBuilder()
.sandbox(sandbox)
.safe(false)
.strict(true));
Map vars = new LinkedHashMap<>();
vars.put("x",  new LinkedHashMap<>());
engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
The code is ok with JDK11, but caused an error "undefined property 'foo'" with 
JDK21.

 

I did some debug and found the problem is

JDK11:  LinkedHashMap implements Map

JDK21: LinkedHashMap implements SequencedMap extends Map

and from 
[JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
{code:java}
                for (final Class inter : clazz.getInterfaces()) {
                    permissions = sandbox.get(inter.getName());
                    if (permissions != null) {
                        if (permissions.isInheritable()) {
                            break;
                        }
                        permissions = null;
                    }
                } {code}
sandbox only checks the direct interfaces but not check it's super interface, 
but for class permission check, it looks into its parents, is it by design or a 
bug?

 

And also because which checking permission of class, it does not check it's 
interface's permission, the result of class is not stable in case parent class 
has permission from it's interface.

for example:
{code:java}
interface I{}
static class A implements I{}
static class B extends A{}

@Test
void testPermission() {
  JexlSandbox sandbox = new JexlSandbox(false, true);
  sandbox.permissions(I.class.getName(), true, true, true, false);
  System.out.println("permission A=" + sandbox.get(A.class.getName()).write());
  System.out.println("permission B=" + sandbox.get(B.class.getName()).write());
}
 {code}
result is 

permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
permission 
B=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13

but if checking B befoer A, the result is 

permission B=org.apache.commons.jexl3.introspection.JexlSandb

[jira] [Updated] (JEXL-424) Permission error after upgraded to JDK 21

2024-06-14 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-424:
--
Description: 
{code:java}
JexlSandbox sandbox = new JexlSandbox(false, true);
sandbox.permissions(Map.class.getName(), true, true, true, true);
...
String jexlCode = "x.foo = 'bar';" 
JexlEngine engine =
new Engine(
new JexlBuilder()
.sandbox(sandbox)
.safe(false)
.strict(true));
Map vars = new LinkedHashMap<>();
vars.put("x",  new LinkedHashMap<>());
engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
The code is ok with JDK11, but caused an error "undefined property 'foo'" with 
JDK21.

 

I did some debug and found the problem is

JDK11:  LinkedHashMap implements Map

JDK21: LinkedHashMap implements SequencedMap extends Map

and from 
[JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
{code:java}
                for (final Class inter : clazz.getInterfaces()) {
                    permissions = sandbox.get(inter.getName());
                    if (permissions != null) {
                        if (permissions.isInheritable()) {
                            break;
                        }
                        permissions = null;
                    }
                } {code}
sandbox only checks the direct interfaces but not check it's super interface, 
but for class permission check, it looks into its parents, is it by design or a 
bug?

 

And also because which checking permission of class, it does not check it's 
interface's permission, the result of class is not stable in case parent class 
has permission from it's interface.

for example:
{code:java}
interface I{}
static class A implements I{}
static class B extends A{}

@Test
void testPermission() {
  JexlSandbox sandbox = new JexlSandbox(false, true);
  sandbox.permissions(I.class.getName(), true, true, true, false);
  System.out.println("permission A=" + sandbox.get(A.class.getName()).write());
  System.out.println("permission B=" + sandbox.get(B.class.getName()).write());
}
 {code}
result is 

permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
permission 
B=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13

but if checking B befoer A, the result is 

permission B=org.apache.commons.jexl3.introspection.JexlSandbox$2@6c1832aa
permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@47ad69f7

 

  was:
{code:java}
JexlSandbox sandbox = new JexlSandbox(false, true);
sandbox.permissions(Map.class.getName(), true, true, true, true);
...
String jexlCode = "x.foo = 'bar';" 
JexlEngine engine =
new Engine(
new JexlBuilder()
.sandbox(sandbox)
.safe(false)
.strict(true));
Map vars = new LinkedHashMap<>();
vars.put("x",  new LinkedHashMap<>());
engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
The code is ok with JDK11, but caused an error "undefined property 'foo'" with 
JDK21.

 

I did some debug and found the problem is

JDK11:  LinkedHashMap implements Map

JDK21: LinkedHashMap implements SequencedMap extends Map

and from 
[JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
{code:java}
                for (final Class inter : clazz.getInterfaces()) {
                    permissions = sandbox.get(inter.getName());
                    if (permissions != null) {
                        if (permissions.isInheritable()) {
                            break;
                        }
                        permissions = null;
                    }
                } {code}
sandbox only checks the direct interfaces but not check it's super interface, 
but for class permission check, it looks into its parents, is it by design or a 
bug.

 

And also because which checking permission of class, it does not check it's 
interface's permission, the result of class is not stable in case parent class 
has permission from it's interface.

for example:
{code:java}
interface I{}
static class A implements I{}
static class B extends A{}

@Test
void testPermission() {
  JexlSandbox sandbox = new JexlSandbox(false, true);
  sandbox.permissions(I.class.getName(), true, true, true, false);
  System.out.println("permission A=" + sandbox.get(A.class.getName()).write());
  System.out.println("permission B=" + sandbox.get(B.class.getName()).write());
}
 {code}
result is 

permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
permission 
B=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13

but if checking B befoer A, the result is 

permission B=org.apache.commons.jexl3.introspection.JexlSandbox$2@6c1832aa
permission 
A=org.apache.commons.jexl3.introsp

[jira] [Created] (JEXL-424) Permission error after upgraded to JDK 21

2024-06-14 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-424:
-

 Summary: Permission error after upgraded to JDK 21
 Key: JEXL-424
 URL: https://issues.apache.org/jira/browse/JEXL-424
 Project: Commons JEXL
  Issue Type: Bug
Affects Versions: 3.3
Reporter: Xu Pengcheng


{code:java}
JexlSandbox sandbox = new JexlSandbox(false, true);
sandbox.permissions(Map.class.getName(), true, true, true, true);
...
String jexlCode = "x.foo = 'bar';" 
JexlEngine engine =
new Engine(
new JexlBuilder()
.sandbox(sandbox)
.safe(false)
.strict(true));
Map vars = new LinkedHashMap<>();
vars.put("x",  new LinkedHashMap<>());
engine.createScript(jexlCode).execute(new MapContext(vars)); {code}
The code is ok with JDK11, but caused an error "undefined property 'foo'" with 
JDK21.

 

I did some debug and found the problem is

JDK11:  LinkedHashMap implements Map

JDK21: LinkedHashMap implements SequencedMap extends Map

and from 
[JexlSandbox.java#L540|https://github.com/apache/commons-jexl/blob/master/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java#L540]]
{code:java}
                for (final Class inter : clazz.getInterfaces()) {
                    permissions = sandbox.get(inter.getName());
                    if (permissions != null) {
                        if (permissions.isInheritable()) {
                            break;
                        }
                        permissions = null;
                    }
                } {code}
sandbox only checks the direct interfaces but not check it's super interface, 
but for class permission check, it looks into its parents, is it by design or a 
bug.

 

And also because which checking permission of class, it does not check it's 
interface's permission, the result of class is not stable in case parent class 
has permission from it's interface.

for example:
{code:java}
interface I{}
static class A implements I{}
static class B extends A{}

@Test
void testPermission() {
  JexlSandbox sandbox = new JexlSandbox(false, true);
  sandbox.permissions(I.class.getName(), true, true, true, false);
  System.out.println("permission A=" + sandbox.get(A.class.getName()).write());
  System.out.println("permission B=" + sandbox.get(B.class.getName()).write());
}
 {code}
result is 

permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13
permission 
B=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@31e04b13

but if checking B befoer A, the result is 

permission B=org.apache.commons.jexl3.introspection.JexlSandbox$2@6c1832aa
permission 
A=org.apache.commons.jexl3.introspection.JexlSandbox$AllowSet@47ad69f7

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-420) Error while comparing float and string value

2024-02-07 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17815516#comment-17815516
 ] 

Xu Pengcheng commented on JEXL-420:
---

I agree that not weaken the type system, but in Java, usually the 'equals' 
method should handle type diff and return false instead of throwing exception.

For java object in JEXL, '==' Equality uses the java equals method, for numeric 
values, I think it is good to try parsing non-numeric object for comparison, 
but personally I think returns false for parsing failure is more consistently, 
and if so, the historic convenient exception for empty string is no need any 
more.

Thanks!

> Error while comparing float and string value
> 
>
> Key: JEXL-420
> URL: https://issues.apache.org/jira/browse/JEXL-420
> Project: Commons JEXL
>  Issue Type: Bug
>Reporter: Xu Pengcheng
>Priority: Major
>
> code:
> {code:java}
> 1.2 == ''{code}
> returns false
>  
> code:
> {code:java}
> 1.2 == 'a'{code}
> causes exception
> {code:java}
> Caused by: java.lang.ArithmeticException: Double coercion: (a){code}
>  
> Is it possible to check the right side is a number like string and return 
> false if not?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-420) Error while comparing float and string value

2024-02-05 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-420:
--
Description: 
code:
{code:java}
1.2 == ''{code}
returns false

 

code:
{code:java}
1.2 == 'a'{code}
causes exception
{code:java}
Caused by: java.lang.ArithmeticException: Double coercion: (a){code}
 

Is it possible to check the right side is a number like string and return false 
if not?

  was:
code:
{code:java}
1.2 == ''{code}
returns false

 

code:
{code:java}
1.2 == 'a'{code}
causes Caused by: java.lang.ArithmeticException: Double coercion: (NE)

 

Is it possible to check the right side is a number like string and return false 
if not?


> Error while comparing float and string value
> 
>
> Key: JEXL-420
> URL: https://issues.apache.org/jira/browse/JEXL-420
> Project: Commons JEXL
>  Issue Type: Bug
>Reporter: Xu Pengcheng
>Priority: Major
>
> code:
> {code:java}
> 1.2 == ''{code}
> returns false
>  
> code:
> {code:java}
> 1.2 == 'a'{code}
> causes exception
> {code:java}
> Caused by: java.lang.ArithmeticException: Double coercion: (a){code}
>  
> Is it possible to check the right side is a number like string and return 
> false if not?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-420) Error while comparing float and string value

2024-02-05 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-420:
--
Description: 
code:
{code:java}
1.2 == ''{code}
returns false

 

code:
{code:java}
1.2 == 'a'{code}
causes Caused by: java.lang.ArithmeticException: Double coercion: (NE)

 

Is it possible to check the right side is a number like string and return false 
if not?

  was:
code: `1.2 == ''` returns false

 

code: `1.2 == 'a'` causes Caused by: java.lang.ArithmeticException: Double 
coercion: (NE)

 

Is it possible to check the right side is a number like string and return false 
if not?


> Error while comparing float and string value
> 
>
> Key: JEXL-420
> URL: https://issues.apache.org/jira/browse/JEXL-420
> Project: Commons JEXL
>  Issue Type: Bug
>Reporter: Xu Pengcheng
>Priority: Major
>
> code:
> {code:java}
> 1.2 == ''{code}
> returns false
>  
> code:
> {code:java}
> 1.2 == 'a'{code}
> causes Caused by: java.lang.ArithmeticException: Double coercion: (NE)
>  
> Is it possible to check the right side is a number like string and return 
> false if not?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-420) Error while comparing float and string value

2024-02-05 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-420:
-

 Summary: Error while comparing float and string value
 Key: JEXL-420
 URL: https://issues.apache.org/jira/browse/JEXL-420
 Project: Commons JEXL
  Issue Type: Bug
Reporter: Xu Pengcheng


code: `1.2 == ''` returns false

 

code: `1.2 == 'a'` causes Caused by: java.lang.ArithmeticException: Double 
coercion: (NE)

 

Is it possible to check the right side is a number like string and return false 
if not?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-418) Add try-catch support

2023-12-12 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-418:
-

 Summary: Add try-catch support
 Key: JEXL-418
 URL: https://issues.apache.org/jira/browse/JEXL-418
 Project: Commons JEXL
  Issue Type: New Feature
Reporter: Xu Pengcheng


Hi,

Is it possible to add try-catch support?

Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-415) incorrect template eval result

2023-11-17 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-415:
-

 Summary: incorrect template eval result
 Key: JEXL-415
 URL: https://issues.apache.org/jira/browse/JEXL-415
 Project: Commons JEXL
  Issue Type: Bug
Reporter: Xu Pengcheng


The following code should return "#1", but actually returns "#${a}"
{code:java}
var a = 1;
return `#${a}`; {code}
I checked the syntax doc, seems there is no such rule.

Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-412) Ambiguous syntax between namespace function call and map object definition.

2023-11-01 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-412:
-

 Summary: Ambiguous syntax between namespace function call and map 
object definition.
 Key: JEXL-412
 URL: https://issues.apache.org/jira/browse/JEXL-412
 Project: Commons JEXL
  Issue Type: Bug
Reporter: Xu Pengcheng


{code:java}
function test() {
  return 'x';
}

let var1 = 'var1';
let x = {
  var1: test(),
  'var2': 1
} {code}
this code caused a parse error.

Looks like the reason is the parser consider `var1: test()` as a namespace 
function call but here I just want define a map keyed by variable.

Is it possible to disable 'namespace' feature to avoid this ambiguous syntax?

Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-406) allow override Engine.createTemplateInterpreter ?

2023-09-22 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17768062#comment-17768062
 ] 

Xu Pengcheng commented on JEXL-406:
---

totally understand and thanks!

> allow override Engine.createTemplateInterpreter ?
> -
>
> Key: JEXL-406
> URL: https://issues.apache.org/jira/browse/JEXL-406
> Project: Commons JEXL
>  Issue Type: Improvement
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.3.1
>
> Attachments: image-2023-09-22-08-57-22-860.png
>
>
> I defined a Interpreter for JexlEngine but found it does not work while 
> evaluating template string, I debugged and found Interpreter of jexl is not 
> applied for TemplateEngine by default.
> I found there is a method createTemplateInterpreter in Engine.class
> {code:java}
> /**
> * Creates a template interpreter.
> * @param args the template interpreter arguments
> */
> protected Interpreter createTemplateInterpreter(final 
> TemplateInterpreter.Arguments args) {
> return new TemplateInterpreter(args);
> }{code}
> But the parameter TemplateInterpreter.Arguments is not visible outside of the 
> package, is it possible to change the visibility so that we can override it?
>  
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-406) allow override Engine.createTemplateInterpreter ?

2023-09-21 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767770#comment-17767770
 ] 

Xu Pengcheng commented on JEXL-406:
---

Thanks

I copied the test to my local project, but failed to run

 

test406:62@1:18 unsolvable function/method 'join(String)'

!image-2023-09-22-08-57-22-860.png|width=480,height=257!

is it the new feature in next release? I am using 3.3 now.

 

And another usage of Interpreter is to change the default behavior of 
evaluating map definition, for example

 
{code:java}
let map = {
  foo: 1
}{code}
we expected the value of map can be evaluated to a map with 'foo' key, ignore 
the value of 'foo' variable, and works even if 'foo' is not defined.

 

In cause to use variable value as map key, code is:

 
{code:java}
let map = {
  [foo]: 1
} {code}
 

 

I overrides visit(final ASTMapEntry node, final Object data)  method in my 
Interpreter to implement this.

 
{code:java}
@Override
@SuppressWarnings("unchecked")
protected Object visit(final ASTMapEntry node, final Object data) {
  JexlNode keyNode = node.jjtGetChild(0);
  Object key;
  if (keyNode instanceof ASTArrayLiteral) {
key = keyNode.jjtAccept(this, data);
if (key instanceof List) {
  List ks = (List) key;
  if (ks.size() == 1) {
key = ks.get(0);
  } else {
throw new JexlException(keyNode, String.format("SyntaxError: Unexpected 
key: %s", key));
  }
} else {
  throw new JexlException(keyNode, String.format("SyntaxError: Unexpected 
key: %s", key));
}
  } else {
key = keyNode.toString();
  }
  final Object value = node.jjtGetChild(1).jjtAccept(this, data);
  return new Object[] {key, value};
} {code}
 

 

Frankly speaking, Interpreter makes JEXL has very good extensibility, not just 
a black box script runner, as I mentioned above, we also use it to calculate 
unit test coverage and some other debug related things.

 

> allow override Engine.createTemplateInterpreter ?
> -
>
> Key: JEXL-406
> URL: https://issues.apache.org/jira/browse/JEXL-406
> Project: Commons JEXL
>  Issue Type: Improvement
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
> Attachments: image-2023-09-22-08-57-22-860.png
>
>
> I defined a Interpreter for JexlEngine but found it does not work while 
> evaluating template string, I debugged and found Interpreter of jexl is not 
> applied for TemplateEngine by default.
> I found there is a method createTemplateInterpreter in Engine.class
> {code:java}
> /**
> * Creates a template interpreter.
> * @param args the template interpreter arguments
> */
> protected Interpreter createTemplateInterpreter(final 
> TemplateInterpreter.Arguments args) {
> return new TemplateInterpreter(args);
> }{code}
> But the parameter TemplateInterpreter.Arguments is not visible outside of the 
> package, is it possible to change the visibility so that we can override it?
>  
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-406) allow override Engine.createTemplateInterpreter ?

2023-09-21 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-406:
--
Attachment: image-2023-09-22-08-57-22-860.png

> allow override Engine.createTemplateInterpreter ?
> -
>
> Key: JEXL-406
> URL: https://issues.apache.org/jira/browse/JEXL-406
> Project: Commons JEXL
>  Issue Type: Improvement
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
> Attachments: image-2023-09-22-08-57-22-860.png
>
>
> I defined a Interpreter for JexlEngine but found it does not work while 
> evaluating template string, I debugged and found Interpreter of jexl is not 
> applied for TemplateEngine by default.
> I found there is a method createTemplateInterpreter in Engine.class
> {code:java}
> /**
> * Creates a template interpreter.
> * @param args the template interpreter arguments
> */
> protected Interpreter createTemplateInterpreter(final 
> TemplateInterpreter.Arguments args) {
> return new TemplateInterpreter(args);
> }{code}
> But the parameter TemplateInterpreter.Arguments is not visible outside of the 
> package, is it possible to change the visibility so that we can override it?
>  
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-406) allow override Engine.createTemplateInterpreter ?

2023-09-21 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767480#comment-17767480
 ] 

Xu Pengcheng commented on JEXL-406:
---

And also we added unit test support for our jexl codes, and use Interpreter to 
mark whether a node was accessed or not to calculate test coverage. 

> allow override Engine.createTemplateInterpreter ?
> -
>
> Key: JEXL-406
> URL: https://issues.apache.org/jira/browse/JEXL-406
> Project: Commons JEXL
>  Issue Type: Improvement
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> I defined a Interpreter for JexlEngine but found it does not work while 
> evaluating template string, I debugged and found Interpreter of jexl is not 
> applied for TemplateEngine by default.
> I found there is a method createTemplateInterpreter in Engine.class
> {code:java}
> /**
> * Creates a template interpreter.
> * @param args the template interpreter arguments
> */
> protected Interpreter createTemplateInterpreter(final 
> TemplateInterpreter.Arguments args) {
> return new TemplateInterpreter(args);
> }{code}
> But the parameter TemplateInterpreter.Arguments is not visible outside of the 
> package, is it possible to change the visibility so that we can override it?
>  
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-406) allow override Engine.createTemplateInterpreter ?

2023-09-21 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767468#comment-17767468
 ] 

Xu Pengcheng commented on JEXL-406:
---

We use Interpreter to wrap object to provider more methods, for example.

 
{code:java}
Class JexlList extends List {
  ... ...
  @Override
  public String join(String splitter) {
// ... ...
  }
}

@Override
@SuppressWarnings("unchecked")
protected Object visit(final ASTIdentifierAccess node, Object data) {
  if (data instanceof List && !(data instanceof JexlList)) {
data = new JexlList((List) data);
  }
  return super.visit(node, data);
}

@Override
@SuppressWarnings("unchecked")
protected Object call(JexlNode node, Object target, Object functor, 
ASTArguments argNode) {
  if (Object instanceof List && !(Object instanceof JexlList)) {
target = new JexlList((List)target);
  }
  return super.call(node, target, functor, argNode));
}{code}
Then all list in jexl context has `join` method.

 

It works while executing script but fails evaluating template.

 

> allow override Engine.createTemplateInterpreter ?
> -
>
> Key: JEXL-406
> URL: https://issues.apache.org/jira/browse/JEXL-406
> Project: Commons JEXL
>  Issue Type: Improvement
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> I defined a Interpreter for JexlEngine but found it does not work while 
> evaluating template string, I debugged and found Interpreter of jexl is not 
> applied for TemplateEngine by default.
> I found there is a method createTemplateInterpreter in Engine.class
> {code:java}
> /**
> * Creates a template interpreter.
> * @param args the template interpreter arguments
> */
> protected Interpreter createTemplateInterpreter(final 
> TemplateInterpreter.Arguments args) {
> return new TemplateInterpreter(args);
> }{code}
> But the parameter TemplateInterpreter.Arguments is not visible outside of the 
> package, is it possible to change the visibility so that we can override it?
>  
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-406) allow override Engine.createTemplateInterpreter ?

2023-09-20 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-406:
-

 Summary: allow override Engine.createTemplateInterpreter ?
 Key: JEXL-406
 URL: https://issues.apache.org/jira/browse/JEXL-406
 Project: Commons JEXL
  Issue Type: Improvement
Reporter: Xu Pengcheng


I defined a Interpreter for JexlEngine but found it does not work while 
evaluating template string, I debugged and found Interpreter of jexl is not 
applied for TemplateEngine by default.

I found there is a method createTemplateInterpreter in Engine.class
{code:java}
/**
* Creates a template interpreter.
* @param args the template interpreter arguments
*/
protected Interpreter createTemplateInterpreter(final 
TemplateInterpreter.Arguments args) {
return new TemplateInterpreter(args);
}{code}
But the parameter TemplateInterpreter.Arguments is not visible outside of the 
package, is it possible to change the visibility so that we can override it?

 

Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-404) error parsing a?['b']

2023-08-30 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-404:
-

 Summary: error parsing a?['b']
 Key: JEXL-404
 URL: https://issues.apache.org/jira/browse/JEXL-404
 Project: Commons JEXL
  Issue Type: Bug
Affects Versions: 3.3
Reporter: Xu Pengcheng


Code example:
{code:java}
var a = {:};
a.b; // ok
a['b'];  // ok
a.b; // ok
a?['b']; // parsing error in ';' {code}
with new JexlBuilder().safe(false).strict(true)

 

Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-404) error parsing a?['b']

2023-08-30 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-404:
--
Description: 
Code example:
{code:java}
var a = {:};
a.b; // ok
a['b'];  // ok
a?.b; // ok
a?['b']; // parsing error in ';' {code}
with new JexlBuilder().safe(false).strict(true)

 

Thanks!

  was:
Code example:
{code:java}
var a = {:};
a.b; // ok
a['b'];  // ok
a.b; // ok
a?['b']; // parsing error in ';' {code}
with new JexlBuilder().safe(false).strict(true)

 

Thanks!


> error parsing a?['b']
> -
>
> Key: JEXL-404
> URL: https://issues.apache.org/jira/browse/JEXL-404
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Priority: Major
>
> Code example:
> {code:java}
> var a = {:};
> a.b; // ok
> a['b'];  // ok
> a?.b; // ok
> a?['b']; // parsing error in ';' {code}
> with new JexlBuilder().safe(false).strict(true)
>  
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-403) Exception while evaluating template literal used in array assignment in loop.

2023-08-29 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-403?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17760176#comment-17760176
 ] 

Xu Pengcheng commented on JEXL-403:
---

great, thanks!

> Exception while evaluating template literal used in array assignment in loop.
> -
>
> Key: JEXL-403
> URL: https://issues.apache.org/jira/browse/JEXL-403
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.3.1
>
>
> code:
> {code:java}
> var a = {'a': 1};
> var list = [a, a];
> let map1 = {:};
> for (var item : list) {
>   map1[`${item.a}`] = 1;
> } {code}
> The fist iteration is ok, but failed at the second time.
> error stack
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.commons.jexl3.internal.introspection.MapSetExecutor cannot be cast 
> to class org.apache.commons.jexl3.internal.TemplateEngine$TemplateExpression 
> (org.apache.commons.jexl3.internal.introspection.MapSetExecutor and 
> org.apache.commons.jexl3.internal.TemplateEngine$TemplateExpression are in 
> unnamed module of loader 'app')
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1909)
>     at 
> org.apache.commons.jexl3.parser.ASTJxltLiteral.jjtAccept(ASTJxltLiteral.java:54)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1558)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1319)
>     at 
> org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:19)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visitBlock(Interpreter.java:615)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:594)
>     at org.apache.commons.jexl3.parser.ASTBlock.jjtAccept(ASTBlock.java:35)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.forIterator(Interpreter.java:700)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:639) 
> {code}
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-403) Failed while evaluating template in loop.

2023-08-29 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-403?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17759998#comment-17759998
 ] 

Xu Pengcheng commented on JEXL-403:
---

I tried at my side and found the problem is caused by setting cache size > 0.
{code:java}
new Engine(new JexlBuilder().cache(100)); {code}
 

BTW, I read the comment of this method but not quite understand what is in 
cache, can you please provide more explanation?

Thanks a lot!

 

 

> Failed while evaluating template in loop.
> -
>
> Key: JEXL-403
> URL: https://issues.apache.org/jira/browse/JEXL-403
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
>
> code:
> {code:java}
> var a = {'a': 1};
> var list = [a, a];
> let map1 = {:};
> for (var item : list) {
>   map1[`${item.a}`] = 1;
> } {code}
> The fist iteration is ok, but failed at the second time.
> error stack
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.commons.jexl3.internal.introspection.MapSetExecutor cannot be cast 
> to class org.apache.commons.jexl3.internal.TemplateEngine$TemplateExpression 
> (org.apache.commons.jexl3.internal.introspection.MapSetExecutor and 
> org.apache.commons.jexl3.internal.TemplateEngine$TemplateExpression are in 
> unnamed module of loader 'app')
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1909)
>     at 
> org.apache.commons.jexl3.parser.ASTJxltLiteral.jjtAccept(ASTJxltLiteral.java:54)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1558)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1319)
>     at 
> org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:19)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visitBlock(Interpreter.java:615)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:594)
>     at org.apache.commons.jexl3.parser.ASTBlock.jjtAccept(ASTBlock.java:35)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.forIterator(Interpreter.java:700)
>     at 
> org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:639) 
> {code}
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-403) Failed while evaluating template in loop.

2023-08-28 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-403:
-

 Summary: Failed while evaluating template in loop.
 Key: JEXL-403
 URL: https://issues.apache.org/jira/browse/JEXL-403
 Project: Commons JEXL
  Issue Type: Bug
Affects Versions: 3.3
Reporter: Xu Pengcheng


code:
{code:java}
var a = {'a': 1};
var list = [a, a];
let map1 = {:};
for (var item : list) {
  map1[`${item.a}`] = 1;
} {code}
The fist iteration is ok, but failed at the second time.

error stack
{code:java}
Caused by: java.lang.ClassCastException: class 
org.apache.commons.jexl3.internal.introspection.MapSetExecutor cannot be cast 
to class org.apache.commons.jexl3.internal.TemplateEngine$TemplateExpression 
(org.apache.commons.jexl3.internal.introspection.MapSetExecutor and 
org.apache.commons.jexl3.internal.TemplateEngine$TemplateExpression are in 
unnamed module of loader 'app')
    at 
org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1909)
    at 
org.apache.commons.jexl3.parser.ASTJxltLiteral.jjtAccept(ASTJxltLiteral.java:54)
    at 
org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1558)
    at 
org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1319)
    at 
org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:19)
    at 
org.apache.commons.jexl3.internal.Interpreter.visitBlock(Interpreter.java:615)
    at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:594)
    at org.apache.commons.jexl3.parser.ASTBlock.jjtAccept(ASTBlock.java:35)
    at 
org.apache.commons.jexl3.internal.Interpreter.forIterator(Interpreter.java:700)
    at 
org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:639) {code}
Thanks!

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-402) parse failed with empty return value.

2023-08-23 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17758067#comment-17758067
 ] 

Xu Pengcheng commented on JEXL-402:
---

Thank you!

> parse failed with empty return value.
> -
>
> Key: JEXL-402
> URL: https://issues.apache.org/jira/browse/JEXL-402
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.3
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Minor
> Fix For: 3.3.1
>
>
> Code:
> {code:java}
> function foo() {
>   return;
> }{code}
> got exception: parsing error in '{'
>  
> but
> {code:java}
> function foo() {
>   return null;
> }{code}
> is ok



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-402) parse failed with empty return value.

2023-08-21 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-402:
-

 Summary: parse failed with empty return value.
 Key: JEXL-402
 URL: https://issues.apache.org/jira/browse/JEXL-402
 Project: Commons JEXL
  Issue Type: Bug
Affects Versions: 3.3
Reporter: Xu Pengcheng


Code:
{code:java}
function foo() {
  return;
}{code}
got exception: parsing error in '{'

 

but
{code:java}
function foo() {
  return null;
}{code}
is ok



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-400) modify primitive value in lambda/function does not affect original value

2023-07-08 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-400:
-

 Summary: modify primitive value in lambda/function does not affect 
original value
 Key: JEXL-400
 URL: https://issues.apache.org/jira/browse/JEXL-400
 Project: Commons JEXL
  Issue Type: Bug
Reporter: Xu Pengcheng


{code:java}
let count = 0;

function inc() {
  count ++;
  // here count is 1
}

inc();
// here count is still 0{code}
It maybe not a 'bug', just seems making it as a global variable and keep the 
value consistently  makes more sense.

Thanks!

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (JEXL-399) Needs support more javascript syntax

2023-07-07 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17741235#comment-17741235
 ] 

Xu Pengcheng edited comment on JEXL-399 at 7/8/23 3:39 AM:
---

Thanks for your explanation.


was (Author: JIRAUSER294041):
Thanks for your explaination.

> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world as a bridge between chatgpt and app.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, I had implements most of the javascript 
> build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
> generated by chatgpt can run successfully.
> However, some syntax error will cause the 5% failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
>  # for (let k in map)
>  # for (let value of map)
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-399) Needs support more javascript syntax

2023-07-07 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17741235#comment-17741235
 ] 

Xu Pengcheng commented on JEXL-399:
---

Thanks for your explaination.

> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world as a bridge between chatgpt and app.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, I had implements most of the javascript 
> build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
> generated by chatgpt can run successfully.
> However, some syntax error will cause the 5% failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
>  # for (let k in map)
>  # for (let value of map)
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-399) Needs support more javascript syntax

2023-07-06 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-399:
--
Description: 
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
generated by chatgpt can run successfully.

However, some syntax error will cause the 5% failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})
 # for (let k in map)
 # for (ket value of map)

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 

  was:
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
generated by chatgpt can run successfully.

However, some syntax error will cause the 5% failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 


> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world as a bridge between chatgpt and app.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, I had implements most of the javascript 
> build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
> generated by chatgpt can run successfully.
> However, some syntax error will cause the 5% failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
>  # for (let k in map)
>  # for (ket value of map)
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-399) Needs support more javascript syntax

2023-07-06 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-399:
--
Description: 
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
generated by chatgpt can run successfully.

However, some syntax error will cause the 5% failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})
 # for (let k in map)
 # for (let value of map)

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 

  was:
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
generated by chatgpt can run successfully.

However, some syntax error will cause the 5% failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})
 # for (let k in map)
 # for (ket value of map)

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 


> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world as a bridge between chatgpt and app.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, I had implements most of the javascript 
> build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
> generated by chatgpt can run successfully.
> However, some syntax error will cause the 5% failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
>  # for (let k in map)
>  # for (let value of map)
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-399) Needs support more javascript syntax

2023-07-06 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-399:
--
Description: 
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 

  was:
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, and I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, and 95% 
cases generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 


> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world as a bridge between chatgpt and app.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, I had implements most of the javascript 
> build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
> generated by chatgpt can run successfully.
> However, some syntax error will cause the failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-399) Needs support more javascript syntax

2023-07-06 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-399:
--
Description: 
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
generated by chatgpt can run successfully.

However, some syntax error will cause the 5% failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 

  was:
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 


> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world as a bridge between chatgpt and app.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, I had implements most of the javascript 
> build-in objects (like Array, Object, Math, console, etc) for JEXL, 95% cases 
> generated by chatgpt can run successfully.
> However, some syntax error will cause the 5% failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-399) Needs support more javascript syntax

2023-07-06 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-399:
--
Description: 
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, and I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, and 95% 
cases generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 

  was:
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, and I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, and 95% 
cases generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

 


> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, and I had implements most of the 
> javascript build-in objects (like Array, Object, Math, console, etc) for 
> JEXL, and 95% cases generated by chatgpt can run successfully.
> However, some syntax error will cause the failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-399) Needs support more javascript syntax

2023-07-06 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-399:
--
Description: 
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world as a bridge between chatgpt and app.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, and I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, and 95% 
cases generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 

  was:
Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, and I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, and 95% 
cases generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

Thanks!

 


> Needs support more javascript syntax
> 
>
> Key: JEXL-399
> URL: https://issues.apache.org/jira/browse/JEXL-399
> Project: Commons JEXL
>  Issue Type: New Feature
>Reporter: Xu Pengcheng
>Priority: Major
>
> Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
> lightweight, secure, easy to communicate with host solution, I think is the 
> best option for java world as a bridge between chatgpt and app.
> Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
> ask chatgpt to write as javascript, and I had implements most of the 
> javascript build-in objects (like Array, Object, Math, console, etc) for 
> JEXL, and 95% cases generated by chatgpt can run successfully.
> However, some syntax error will cause the failure, for example:
>  # a === b
>  # a !== b
>  # a = b ** 2
>  # const \{a, b} = x;
>  # a = \{x: 1, y: 2,}
>  # func = () => (\{"a":1, "b": 2})
> These syntax looks very reasonable, It will be great to support these 
> javascript syntax to let both chatgpt and developer easy to use.
> Thanks!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-399) Needs support more javascript syntax

2023-07-06 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-399:
-

 Summary: Needs support more javascript syntax
 Key: JEXL-399
 URL: https://issues.apache.org/jira/browse/JEXL-399
 Project: Commons JEXL
  Issue Type: New Feature
Reporter: Xu Pengcheng


Hi, I am trying ask chatgpt to generate code for some cases, JEXL, as a 
lightweight, secure, easy to communicate with host solution, I think is the 
best option for java world.

Unfortunately, chatgpt seems is not familiar with Jexl syntax, so I tried to 
ask chatgpt to write as javascript, and I had implements most of the javascript 
build-in objects (like Array, Object, Math, console, etc) for JEXL, and 95% 
cases generated by chatgpt can run successfully.

However, some syntax error will cause the failure, for example:
 # a === b
 # a !== b
 # a = b ** 2
 # const \{a, b} = x;
 # a = \{x: 1, y: 2,}
 # func = () => (\{"a":1, "b": 2})

These syntax looks very reasonable, It will be great to support these 
javascript syntax to let both chatgpt and developer easy to use.

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-398) Allow 'trailing commas' while define a map

2023-06-24 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-398:
-

 Summary: Allow 'trailing commas' while define a map
 Key: JEXL-398
 URL: https://issues.apache.org/jira/browse/JEXL-398
 Project: Commons JEXL
  Issue Type: New Feature
Reporter: Xu Pengcheng


For example, 

 
{code:java}
let m = {
  "foo": 1,
  "bar": 2,
}{code}
It fails because there is a comma after last entry `"bar": 2`,  do we have any 
plan to support it?

Thanks!

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (JEXL-383) Inconsistent behavior after overriding toBoolean method in JexlArithmetic

2022-11-06 Thread Xu Pengcheng (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17629497#comment-17629497
 ] 

Xu Pengcheng commented on JEXL-383:
---

Thanks!

Looks like  isStrict(JexlOperator operator) api of JexlArithmetic is not in 
3.2.1, what is the next release time?

> Inconsistent behavior after overriding toBoolean method in JexlArithmetic
> -
>
> Key: JEXL-383
> URL: https://issues.apache.org/jira/browse/JEXL-383
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.2.1
>Reporter: Xu Pengcheng
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.3
>
>
> I tried to overriding "toBoolean" method of JexlArithmetic for 'strict' mode.
> {code:java}
> @Override
> public boolean toBoolean(final Object val) {
>   if (val == null) {
> return false;
>   } else {
> return super.toBoolean(val);
>   }
> } {code}
>  while executing code:
> parameters:
> {code:java}
> a: null
> {code}
> but while executing scripts, the behavior is inconsistent
> {code:java}
> if (a) return 1 else return 2;  // returns 2
> if (!a) return 1 else return 2; // expects return 1 but throws exception: 
> variable 'a' is null{code}
>  
> what should I do to fix it? thanks!
> -Pengcheng
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (JEXL-383) Inconsistent behavior after overriding toBoolean method in JexlArithmetic

2022-11-02 Thread Xu Pengcheng (Jira)


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

Xu Pengcheng updated JEXL-383:
--
Description: 
I tried to overriding "toBoolean" method of JexlArithmetic for 'strict' mode.
{code:java}
@Override
public boolean toBoolean(final Object val) {
  if (val == null) {
return false;
  } else {
return super.toBoolean(val);
  }
} {code}
 while executing code:

parameters:
{code:java}
a: null
{code}
but while executing scripts, the behavior is inconsistent
{code:java}
if (a) return 1 else return 2;  // returns 2
if (!a) return 1 else return 2; // expects return 1 but throws exception: 
variable 'a' is null{code}
 

what should I do to fix it? thanks!

-Pengcheng

 

 

  was:
I tried to overriding "toBoolean" method of JexlArithmetic for 'strict' mode.
{code:java}
@Override
public boolean toBoolean(final Object val) {
  if (val == null) {
return false;
  } else {
return super.toBoolean(val);
  }
} {code}
 while executing code:

parameters:
{code:java}
a: null
{code}
but while executing scripts, the behavior is inconsistent
{code:java}
if (a) return 1 else return 2;  // returns 2
if (!a) return 1 else return 2; // expect returns 1 but throws exception: 
variable 'a' is null{code}
 

what should I do to fix it? thanks!

-Pengcheng

 

 


> Inconsistent behavior after overriding toBoolean method in JexlArithmetic
> -
>
> Key: JEXL-383
> URL: https://issues.apache.org/jira/browse/JEXL-383
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.2.1
>Reporter: Xu Pengcheng
>Priority: Major
>
> I tried to overriding "toBoolean" method of JexlArithmetic for 'strict' mode.
> {code:java}
> @Override
> public boolean toBoolean(final Object val) {
>   if (val == null) {
> return false;
>   } else {
> return super.toBoolean(val);
>   }
> } {code}
>  while executing code:
> parameters:
> {code:java}
> a: null
> {code}
> but while executing scripts, the behavior is inconsistent
> {code:java}
> if (a) return 1 else return 2;  // returns 2
> if (!a) return 1 else return 2; // expects return 1 but throws exception: 
> variable 'a' is null{code}
>  
> what should I do to fix it? thanks!
> -Pengcheng
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-383) Inconsistent behavior after overriding toBoolean method in JexlArithmetic

2022-11-02 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-383:
-

 Summary: Inconsistent behavior after overriding toBoolean method 
in JexlArithmetic
 Key: JEXL-383
 URL: https://issues.apache.org/jira/browse/JEXL-383
 Project: Commons JEXL
  Issue Type: Bug
Affects Versions: 3.2.1
Reporter: Xu Pengcheng


I tried to overriding "toBoolean" method of JexlArithmetic for 'strict' mode.
{code:java}
@Override
public boolean toBoolean(final Object val) {
  if (val == null) {
return false;
  } else {
return super.toBoolean(val);
  }
} {code}
 while executing code:

parameters:
{code:java}
a: null
{code}
but while executing scripts, the behavior is inconsistent
{code:java}
if (a) return 1 else return 2;  // returns 2
if (!a) return 1 else return 2; // expect returns 1 but throws exception: 
variable 'a' is null{code}
 

what should I do to fix it? thanks!

-Pengcheng

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (JEXL-377) Add support for javascript style function definition

2022-08-06 Thread Xu Pengcheng (Jira)
Xu Pengcheng created JEXL-377:
-

 Summary: Add support for javascript style function definition
 Key: JEXL-377
 URL: https://issues.apache.org/jira/browse/JEXL-377
 Project: Commons JEXL
  Issue Type: Improvement
Reporter: Xu Pengcheng


It would be nice to allow the Javascript function definition:
{code:java}
function add(x, y) {
  return x + y;
}{code}
Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)