commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1813542 - in /commons/proper/jexl/trunk/src: main/java/org/apache/commons/jexl3/internal/Interpreter.java test/java/org/apache/commons/jexl3/AntishCallTest.java
Date Fri, 27 Oct 2017 15:11:38 GMT
Author: henrib
Date: Fri Oct 27 15:11:38 2017
New Revision: 1813542

URL: http://svn.apache.org/viewvc?rev=1813542&view=rev
Log:
JEXL-240:
Reverting to not considering class objects as functor (by default).

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AntishCallTest.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java?rev=1813542&r1=1813541&r2=1813542&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
(original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
Fri Oct 27 15:11:38 2017
@@ -1602,12 +1602,6 @@ public class Interpreter extends Interpr
                     if (functor instanceof JexlMethod) {
                         return ((JexlMethod) functor).invoke(target, argv);
                     }
-                    if (functor instanceof Class<?>) {
-                        vm = uberspect.getConstructor(functor, argv);
-                        if (vm != null) {
-                            return vm.invoke(functor, argv);
-                        }
-                    }
                     // a generic callable
                     mname = "call";
                     vm = uberspect.getMethod(functor, mname, argv);

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AntishCallTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AntishCallTest.java?rev=1813542&r1=1813541&r2=1813542&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AntishCallTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AntishCallTest.java Fri
Oct 27 15:11:38 2017
@@ -36,11 +36,12 @@ public class AntishCallTest extends Jexl
      * Wraps a class.
      */
     public class ClassReference {
-        Class<?> clazz;
+        final Class<?> clazz;
         ClassReference(Class<?> c) {
             this.clazz = c;
         }
     }
+
     /**
      * Considers any call using a class reference as functor as a call to its constructor.
      * <p>Note that before 3.2, a class was not considered a functor.
@@ -77,6 +78,10 @@ public class AntishCallTest extends Jexl
         public Object call(ClassReference clazz, Object... args) {
             return callConstructor(null, clazz, args);
         }
+
+        public Object call(Class<?> clazz, Object... args) {
+            return callConstructor(null, clazz, args);
+        }
     }
 
     /**
@@ -118,25 +123,17 @@ public class AntishCallTest extends Jexl
         public Object call(ClassReference clazz, Object... args) {
             return callConstructor(engine, clazz, args);
         }
-    }
 
-    @Test
-    public void testAntishAContextVar() throws Exception {
-        JexlEngine jexl = new JexlBuilder().cache(512).strict(true).silent(false).create();
-        Map<String,Object> lmap = new TreeMap<String,Object>();
-        JexlContext jc = new CallSupportContext(lmap).engine(jexl);
-        runTestCall(jexl, jc);
-        lmap.put("java.math.BigInteger", new ClassReference(java.math.BigInteger.class));
-        runTestCall(jexl, jc);
-        lmap.remove("java.math.BigInteger");
-        runTestCall(jexl, jc);
+        public Object call(Class<?> clazz, Object... args) {
+            return callConstructor(engine, clazz, args);
+        }
     }
 
     @Test
-    public void testAntishAContextVar2() throws Exception {
+    public void testAntishContextVar() throws Exception {
         JexlEngine jexl = new JexlBuilder().cache(512).strict(true).silent(false).create();
         Map<String,Object> lmap = new TreeMap<String,Object>();
-        JexlContext jc = new CallSupportContext(lmap);
+        JexlContext jc = new CallSupportContext(lmap).engine(jexl);
         runTestCall(jexl, jc);
         lmap.put("java.math.BigInteger", new ClassReference(java.math.BigInteger.class));
         runTestCall(jexl, jc);
@@ -165,13 +162,13 @@ public class AntishCallTest extends Jexl
 
     void runTestCall(JexlEngine jexl, JexlContext jc) throws Exception {
         JexlScript check1 = jexl.createScript("var x = java.math.BigInteger; x('1234')");
-        JexlScript check2 = jexl.createScript("java.math.BigInteger('1234')");
+        JexlScript check2 = jexl.createScript("java.math.BigInteger('4321')");
 
         Object o1 = check1.execute(jc);
         Assert.assertEquals("Result is not 1234", new java.math.BigInteger("1234"), o1);
 
         Object o2 = check2.execute(jc);
-        Assert.assertEquals("Result is not 1234", new java.math.BigInteger("1234"), o2);
+        Assert.assertEquals("Result is not 4321", new java.math.BigInteger("4321"), o2);
     }
 
 }
\ No newline at end of file



Mime
View raw message