I'm new to using JEXL and was surprised by the following behavior (see code
below). Obviously "badMethodName()" is not a method on the String "bar". I
expected JEXL to throw some appropriate exception. Rather, JEXL returned
null for the call, which is not a good thing, IMHO. Switching
"badMethodName() for a non-existing property call like
"properties['foo'].qux" also returns null.

I've stepped through the code and the behavior seems intentional.

Am I missing something, or is this a philosophical thing with JEXL? Trying
similar tests with JUEL, which is an implementation of the Java Unified
Expression Language throws exceptions as I expected.

I would much rather use JEXL however, but need to resolve this issue.

public void testPropertyExpression() throws Exception
    Properties properties = new Properties();
    properties.put("foo", "bar");

    JexlContext context = JexlHelper.createContext();
    context.getVars().put("properties", properties);

    Expression e = ExpressionFactory.createExpression
    String value = (String) e.evaluate(context);
    assertEquals("huh", value);

Thanks in advance,


Reply via email to