aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'velocity-engine-core/src/main/java')
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java22
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java5
2 files changed, 23 insertions, 4 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
index c7fab881..29a6739b 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
@@ -334,10 +334,26 @@ public class ASTMethod extends SimpleNode
*/
public static class MethodCacheKey
{
+ /**
+ * method name
+ */
private final String methodName;
+
+ /**
+ * parameters classes
+ */
private final Class[] params;
- public MethodCacheKey(String methodName, Class[] params)
+ /**
+ * whether the target object is of Class type
+ * (meaning we're searching either for methods
+ * of Class, or for static methods of the class
+ * this Class objects refers to)
+ * @since 2.2
+ */
+ private boolean classObject;
+
+ public MethodCacheKey(String methodName, Class[] params, boolean classObject)
{
/**
* Should never be initialized with nulls, but to be safe we refuse
@@ -345,6 +361,7 @@ public class ASTMethod extends SimpleNode
*/
this.methodName = (methodName != null) ? methodName : StringUtils.EMPTY;
this.params = (params != null) ? params : EMPTY_CLASS_ARRAY;
+ this.classObject = classObject;
}
/**
@@ -360,7 +377,8 @@ public class ASTMethod extends SimpleNode
{
final MethodCacheKey other = (MethodCacheKey) o;
if (params.length == other.params.length &&
- methodName.equals(other.methodName))
+ methodName.equals(other.methodName) &&
+ classObject == other.classObject)
{
for (int i = 0; i < params.length; ++i)
{
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
index d33bd978..b17eb681 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
@@ -179,9 +179,10 @@ public class ClassUtils {
/*
* check the cache
*/
- MethodCacheKey mck = new MethodCacheKey(methodName, paramClasses);
+ boolean classObject = (o instanceof Class);
+ MethodCacheKey mck = new MethodCacheKey(methodName, paramClasses, classObject);
IntrospectionCacheData icd = context.icacheGet(mck);
- Class clazz = o instanceof Class ? (Class)o : o.getClass();
+ Class clazz = classObject ? (Class)o : o.getClass();
/*
* like ASTIdentifier, if we have cache information, and the Class of