Hi,
if the empty() function is called for variable containing int[] it causes an
exception:
java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:715)
at
org.apache.commons.jexl2.parser.ASTEmptyFunction.jjtAccept(ASTEmptyFunction.java:18)
at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:1364)
at
org.apache.commons.jexl2.parser.ASTReturnStatement.jjtAccept(ASTReturnStatement.java:18)
at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:946)
at
org.apache.commons.jexl2.parser.ASTJexlScript.jjtAccept(ASTJexlScript.java:38)
at org.apache.commons.jexl2.Interpreter.interpret(Interpreter.java:232)
at
org.apache.commons.jexl2.ExpressionImpl.execute(ExpressionImpl.java:107)
See the example below.
BTW how an empty map could be created? The {} literal is not valid jexl syntax.
Best regards,
Tomas
---------------------------------
public class Test04 {
private final static String[] SCRIPTS = {
"var x = null; return empty(x);",
"var x = ''; return empty(x);",
"var x = 'abc'; return empty(x);",
"var x = 0; return empty(x);",
"var x = 333; return empty(x);",
"var x = []; return empty(x);",
"var x = [1, 2]; return empty(x);", // === ERROR ===
"var x = ['a', 'b']; return empty(x);",
// "var x = {}; return empty(x);",
"var x = {1:'A', 2:'B'}; return empty(x);",
};
public static void main(String[] args) {
JexlEngine jexl = new JexlEngine();
JexlContext jc = new MapContext();
Script script;
for (String stext : SCRIPTS) {
System.out.println(stext);
script = jexl.createScript(stext);
try {
Object ret = script.execute(jc);
System.out.println(ret);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]