aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src/main/java/org/apache
diff options
context:
space:
mode:
authorClaude Brisson <cbrisson@apache.org>2017-04-14 10:20:25 +0000
committerClaude Brisson <cbrisson@apache.org>2017-04-14 10:20:25 +0000
commiteb472a3bc287228fb3bcce702cd81f048a6cbb9b (patch)
tree931e81d826093708d50bddddfdb5e27921420f3b /velocity-engine-core/src/main/java/org/apache
parentf67cf19adcce14ecf4fac512d79c838524a91942 (diff)
downloadapache-velocity-engine-eb472a3bc287228fb3bcce702cd81f048a6cbb9b.tar.gz
[engine] Fix vararg methods disambiguation
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1791334 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src/main/java/org/apache')
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java
index a6e91b8e..3fcdccee 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java
@@ -329,8 +329,8 @@ public class MethodMap
*/
private int compare(Class[] c1, Class[] c2)
{
- boolean c1MoreSpecific = false;
- boolean c2MoreSpecific = false;
+ boolean c1IsVararag = false;
+ boolean c2IsVararag = false;
boolean fixedLengths = false;
// compare lengths to handle comparisons where the size of the arrays
@@ -351,10 +351,12 @@ public class MethodMap
if (itemClass == null)
{
/* by construct, we have c1.length = l2 + 1 */
- c2[c1.length - 1] = c1[c1.length - 1];
+ c1IsVararag = true;
+ c2[c1.length - 1] = null;
}
else
{
+ c2IsVararag = true;
for (int i = l2 - 1; i < c1.length; ++i)
{
/* also overwrite the vaargs itself */
@@ -378,10 +380,12 @@ public class MethodMap
if (itemClass == null)
{
/* by construct, we have c2.length = l1 + 1 */
- c1[c2.length - 1] = c2[c2.length - 1];
+ c2IsVararag = true;
+ c1[c2.length - 1] = null;
}
else
{
+ c1IsVararag = true;
for (int i = l1 - 1; i < c2.length; ++i)
{
/* also overwrite the vaargs itself */
@@ -468,8 +472,8 @@ public class MethodMap
* If one method accepts varargs and the other does not,
* call the non-vararg one more specific.
*/
- boolean last1Array = !fixedLengths && c1[c1.length - 1].isArray();
- boolean last2Array = !fixedLengths && c2[c2.length - 1].isArray();
+ boolean last1Array = c1IsVararag || !fixedLengths && c1[c1.length - 1].isArray();
+ boolean last2Array = c2IsVararag || !fixedLengths && c2[c2.length - 1].isArray();
if (last1Array && !last2Array)
{
return LESS_SPECIFIC;