commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "freish (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JEXL-132) divide zero error and others
Date Fri, 11 May 2012 08:15:59 GMT
freish created JEXL-132:
---------------------------

             Summary: divide zero error and others
                 Key: JEXL-132
                 URL: https://issues.apache.org/jira/browse/JEXL-132
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 2.0.1
         Environment: JEXL2.0.1 jdk1.5.0_22
            Reporter: freish


code snippet:
		String exp;
		Expression expression;
		JexlEngine engine = new JexlEngine();

		
		exp = "1/0";
		expression = engine.createExpression(exp);
		System.out.println(expression.evaluate(null));

this will print 0.0,shoud it indicate an error by throwing exception or return value?
----------------------------------------------


code snippet:
		exp = "1/0.0";
		expression = engine.createExpression(exp);
		System.out.println(expression.evaluate(null));
this will print 0.0 too,but in fact it should return Infinity.
----------------------------------------------


code snippet:
		exp = "Math.abs(-1)";
		expression = engine.createExpression(exp);
		System.out.println(expression.evaluate(null));

I don't know whether this is a bug.JEXL cannot invoke java static method directly,it will
throw an exception
----------------------------------------------



code snippet:
		exp = "a.abs(-1)";
		class MyMath {
			public double abs(double d) {
				return Math.abs(d);
			} 
		}
		Object obj = new MyMath();
		expression = engine.createExpression(exp);
		MapContext c = new MapContext();
		c.set("a", obj);
		System.out.println(expression.evaluate(c));

er,this is very strange,if MyMath is not public(whether in a independent file or not),it will
return null;but if MyMath is a public class,it will behave correctly


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message