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

Andriy Rysin commented on JEXL-443:
-----------------------------------

Ahh, thank you for the prompt reply.

Setting permissions helps, e.g.
{code:java}
permissions(JexlPermissions.UNRESTRICTED){code}
I just could not find any example with that code quickly online (and neither 
did copilot).

 

I wonder if we should explicitly say permissions not allowed in the error 
message, unless we don't want to expose that for security reasons. But then if 
I am setting the object to the context, not sure what would be the purpose if I 
can't access any of its fields.

> ObjectContext can't find fields with jexl3 >= 3.3
> -------------------------------------------------
>
>                 Key: JEXL-443
>                 URL: https://issues.apache.org/jira/browse/JEXL-443
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.3, 3.4.0, 3.5.0
>         Environment: Linux / JDK 21
> Windows / JDK 17
>            Reporter: Andriy Rysin
>            Assignee: Henri Biestro
>            Priority: Major
>
> I'm creating simple ObjectContext and with jexl3 >= 3.3 I am getting 
> "variable 'param1' is undefined". This example works on jexl3 3.2.1.
> Surprisingly neither version can find "param0" even though getParam0() works.
>  
> {code:java}
> public class JexlTest {
>     @Test
>     public void testJexlFields() throws Exception {
>         JexlEngine jexl = new JexlBuilder()
>                 .cache(0)
>                 .strict(true)
>                 .silent(false)
>                 .create();
>         
>         Parameters object = new Parameters();
>         object.setParam1(Enum1.VALUE1);
>         JexlContext context = new ObjectContext<>(jexl, object);
>         jexl.createExpression("param1").evaluate(context);
> //        jexl.createExpression("param0").evaluate(context);
>         jexl.createExpression("getParam0()").evaluate(context);
>     }
>     
>     public static class Parameters {
>         private String param0;
>         private Enum1 param1;
>         
>         public String getParam0() {
>             return param0;
>         }
>         public void setParam0(String param0) {
>             this.param0 = param0;
>         }
>         public Enum1 getParam1() {
>             return param1;
>         }
>         public void setParam1(Enum1 param1) {
>             this.param1 = param1;
>         }
>         
>     }
>     public enum Enum1 {
>         VALUE1
>     }
> }
> {code}
>  



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

Reply via email to