You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2022/08/29 13:37:48 UTC
[commons-jexl] branch master updated: JEXL-317: regression fix, in derived class, method with same signature of a private base method is accessible;
This is an automated email from the ASF dual-hosted git repository.
henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push:
new 0ebbaea7 JEXL-317: regression fix, in derived class, method with same signature of a private base method is accessible;
0ebbaea7 is described below
commit 0ebbaea7ec667712878d05d2b5ab94c693f5daef
Author: henrib <he...@apache.org>
AuthorDate: Mon Aug 29 15:37:43 2022 +0200
JEXL-317: regression fix, in derived class, method with same signature of a private base method is accessible;
---
.../jexl3/internal/introspection/Permissions.java | 5 ----
.../internal/introspection/PermissionsTest.java | 30 ++++++++++++++++++++++
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java
index 582bce3e..177cf7a4 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java
@@ -367,11 +367,6 @@ public class Permissions implements JexlPermissions {
* @return true if denied, false otherwise
*/
private boolean deny(Method method) {
- // private are denied
- int modifiers = method.getModifiers();
- if (Modifier.isPrivate(modifiers)) {
- return true;
- }
// is method annotated with nojexl ?
final NoJexl nojexl = method.getAnnotation(NoJexl.class);
if (nojexl != null) {
diff --git a/src/test/java/org/apache/commons/jexl3/internal/introspection/PermissionsTest.java b/src/test/java/org/apache/commons/jexl3/internal/introspection/PermissionsTest.java
index d516601c..6bf36179 100644
--- a/src/test/java/org/apache/commons/jexl3/internal/introspection/PermissionsTest.java
+++ b/src/test/java/org/apache/commons/jexl3/internal/introspection/PermissionsTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.commons.jexl3.internal.introspection;
+import org.apache.commons.jexl3.JexlArithmetic;
import org.apache.commons.jexl3.JexlBuilder;
import org.apache.commons.jexl3.JexlContext;
import org.apache.commons.jexl3.JexlEngine;
@@ -372,4 +373,33 @@ public class PermissionsTest {
Object result = script.execute(context, a);
Assert.assertNotNull(result);
}
+
+ public class I33Arithmetic extends JexlArithmetic {
+ public I33Arithmetic(boolean astrict) {
+ super(astrict);
+ }
+
+ /**
+ * Same name signature as default private method.
+ * @param s the string
+ * @return a double, NaN if fail
+ */
+ public double parseDouble(String s) {
+ try {
+ return Double.parseDouble(s);
+ } catch (NumberFormatException nfe) {
+ return Double.NaN;
+ }
+ }
+ }
+
+ @Test public void testPrivateOverload1() throws Exception {
+ String src = "parseDouble(\"PHM1\".substring(3)).intValue()";
+ JexlArithmetic jexla = new I33Arithmetic(true);
+ JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(jexla).create();
+ JexlScript script = jexl.createScript(src);
+ Assert.assertNotNull(script);
+ Object result = script.execute(null);
+ Assert.assertEquals(1, result);
+ }
}