commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Kuznetsov (JIRA)" <j...@apache.org>
Subject [jira] Created: (JEXL-48) NPE during expression evaluation
Date Thu, 02 Oct 2008 09:05:44 GMT
NPE during expression evaluation
--------------------------------

                 Key: JEXL-48
                 URL: https://issues.apache.org/jira/browse/JEXL-48
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 1.1
         Environment: Java 1.6.0 update 07
            Reporter: Alexey Kuznetsov


When we use '=' instead of '==' we'll get NullPointerException

public class Main {

    public static class Another {
        private Boolean foo = true;
        
        
        public Boolean foo()
        {
            return foo;
        }
        
        public int goo()
        {
            return 100;
        }
        
    }
    
    public static class Foo {
        private Another inner;
        
        public Foo() {
            inner = new Another();
        }

        public Another getInner()
        {
            return inner;
        }
        
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        String jexlExp = "(foo.getInner().foo() eq true) and (foo.getInner().goo() = (foo.getInner().goo()+1-1))";
        Expression e = ExpressionFactory.createExpression( jexlExp );

        // Create a context and add data
        JexlContext jc = JexlHelper.createContext();
        jc.getVars().put("foo", new Foo() );

        // Now evaluate the expression, getting the result
        Object o = e.evaluate(jc);
        
        System.out.println("Result: "+o);
    }

}




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message