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 2020/09/13 15:13:44 UTC
[commons-jexl] branch master updated: JEXL-333: fixed namespace
resolution on static only (private ctor) classes (take 2) Task #JEXL-333 -
Allow declaration of namespace within script
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 25ad5ed JEXL-333: fixed namespace resolution on static only (private ctor) classes (take 2) Task #JEXL-333 - Allow declaration of namespace within script
25ad5ed is described below
commit 25ad5edae220afeccd123a621079c465e3002350
Author: henrib <he...@apache.org>
AuthorDate: Sun Sep 13 17:13:18 2020 +0200
JEXL-333: fixed namespace resolution on static only (private ctor) classes (take 2)
Task #JEXL-333 - Allow declaration of namespace within script
---
.../org/apache/commons/jexl3/internal/InterpreterBase.java | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java b/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java
index 557ca19..16402e3 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java
@@ -199,8 +199,8 @@ public abstract class InterpreterBase extends ParserVisitor {
throw new JexlException(node, "unable to instantiate namespace " + prefix, xtry.getCause());
}
}
+ // find a ctor with that context class
if (functor == null) {
- // find a ctor with that context class
JexlMethod ctor = uberspect.getConstructor(namespace, context);
if (ctor != null) {
try {
@@ -212,7 +212,7 @@ public abstract class InterpreterBase extends ParserVisitor {
throw new JexlException(node, "unable to instantiate namespace " + prefix, xinst);
}
}
- // find a ctor with no arg
+ // try again; find a ctor with no arg
if (functor == null) {
ctor = uberspect.getConstructor(namespace);
if (ctor != null) {
@@ -222,19 +222,17 @@ public abstract class InterpreterBase extends ParserVisitor {
throw new JexlException(node, "unable to instantiate namespace " + prefix, xinst);
}
}
- // use a class, namespace of static methods
+ // try again; use a class, namespace of static methods
if (functor == null) {
// try to find a class with that name
if (namespace instanceof String) {
try {
- functor = uberspect.getClassLoader().loadClass((String) namespace);
+ namespace = uberspect.getClassLoader().loadClass((String) namespace);
} catch (ClassNotFoundException xignore) {
// not a class
namespace = null;
}
- } else { // we know its a class
- functor = (Class<?>) namespace;
- }
+ } // we know its a class
}
}
}