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

Vyacheslav Shago updated JEXL-225:
----------------------------------
    Description: 
After apply fix in [JEXL-190|https://issues.apache.org/jira/browse/JEXL-190] 
folowing code doesn't work anymore:
{code}
public class Example {
    public static void main(String[] args) {
        JexlEngine jexl = new JexlBuilder().create();

        ObjectContext<Foo> context = new ObjectContext<>(jexl, new Foo());
        JexlExpression expression = jexl.createExpression("bar()");

        System.out.println(expression.evaluate(context));
    }

    public static class Foo extends HashMap<String, Object>{
        public String bar(){
            return "bar";
        }
    }
}
{code}


Also doesn't work this code (note: with MapContext all working correct):
{code}
public class Example {
    public static void main(String[] args) {
        HashMap<String, Object> functions = new HashMap<>();
        functions.put(null, new DefaultFunctions());

        JexlEngine jexl = new JexlBuilder()
                .namespaces(functions)
                .create();

        ObjectContext<Object> context = new ObjectContext<>(jexl, new Object());
        JexlExpression expression = jexl.createExpression("bar()");

        System.out.println(expression.evaluate(context));
    }

    public static class DefaultFunctions {
        public String bar(){
            return "bar";
        }
    }
}
{code}

  was:
After apply fix in [JEXL-190|https://issues.apache.org/jira/browse/JEXL-190] 
folowing code doesn't work anymore:
{code}
public class Example {
    public static void main(String[] args) {
        JexlEngine jexl = new JexlBuilder().create();

        ObjectContext<Foo> context = new ObjectContext<>(jexl, new Foo());
        JexlExpression expression = jexl.createExpression("bar()");

        System.out.println(expression.evaluate(context));
    }

    public static class Foo extends HashMap<String, Object>{
        public String bar(){
            return "bar";
        }
    }
}
{code}

Also doesn't work this code:
{code}
public class Example {
    public static void main(String[] args) {
        HashMap<String, Object> functions = new HashMap<>();
        functions.put(null, new DefaultFunctions());

        JexlEngine jexl = new JexlBuilder()
                .namespaces(functions)
                .create();

        ObjectContext<Object> context = new ObjectContext<>(jexl, new Object());
        JexlExpression expression = jexl.createExpression("bar()");

        System.out.println(expression.evaluate(context));
    }

    public static class DefaultFunctions {
        public String bar(){
            return "bar";
        }
    }
}
{code}


> Incorrect invoking methods with ObjectContext
> ---------------------------------------------
>
>                 Key: JEXL-225
>                 URL: https://issues.apache.org/jira/browse/JEXL-225
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.1
>            Reporter: Vyacheslav Shago
>
> After apply fix in [JEXL-190|https://issues.apache.org/jira/browse/JEXL-190] 
> folowing code doesn't work anymore:
> {code}
> public class Example {
>     public static void main(String[] args) {
>         JexlEngine jexl = new JexlBuilder().create();
>         ObjectContext<Foo> context = new ObjectContext<>(jexl, new Foo());
>         JexlExpression expression = jexl.createExpression("bar()");
>         System.out.println(expression.evaluate(context));
>     }
>     public static class Foo extends HashMap<String, Object>{
>         public String bar(){
>             return "bar";
>         }
>     }
> }
> {code}
> Also doesn't work this code (note: with MapContext all working correct):
> {code}
> public class Example {
>     public static void main(String[] args) {
>         HashMap<String, Object> functions = new HashMap<>();
>         functions.put(null, new DefaultFunctions());
>         JexlEngine jexl = new JexlBuilder()
>                 .namespaces(functions)
>                 .create();
>         ObjectContext<Object> context = new ObjectContext<>(jexl, new 
> Object());
>         JexlExpression expression = jexl.createExpression("bar()");
>         System.out.println(expression.evaluate(context));
>     }
>     public static class DefaultFunctions {
>         public String bar(){
>             return "bar";
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to