On 05/17/2012 11:20 AM, Adam Heath wrote: > On 05/17/2012 10:57 AM, Adam Heath wrote: >> On 05/17/2012 10:56 AM, Jacopo Cappellato wrote: >>> Looks good to me, are you going to attach it to the ticket I have created >>> in the Freemarker bug tracker? >> >> I'll do it; what's the other bug#? Do we want to bump the severity? > > I'm just waiting on greylisting on our mailserver to allow it thru, > then'll the attachment will be there.
While waiting, I made a patch, seems to fix it.
diff --git a/freemarker/src/freemarker/ext/beans/ClassString.java b/freemarker/src/freemarker/ext/beans/ClassString.java index 2cdee9b..81d1b3f 100644 --- a/freemarker/src/freemarker/ext/beans/ClassString.java +++ b/freemarker/src/freemarker/ext/beans/ClassString.java @@ -75,7 +75,7 @@ final class ClassString classes = new Class[l]; for(int i = 0; i < l; ++i) { Object obj = objects[i]; - classes[i] = obj == null ? MethodUtilities.OBJECT_CLASS : obj.getClass(); + classes[i] = obj == null ? MethodUtilities.WILDCARD_CLASS : obj.getClass(); } } @@ -293,13 +293,16 @@ final class ClassString // conversion, not widening. return isBigDecimalConvertible(formal, actual); } + if (actual == MethodUtilities.WILDCARD_CLASS) { + return true; + } return false; } private static boolean isBigDecimalConvertible(Class formal, Class actual) { // BigDecimal - if(BIGDECIMAL_CLASS.isAssignableFrom(actual)) + if(BIGDECIMAL_CLASS.isAssignableFrom(actual) || actual == MethodUtilities.WILDCARD_CLASS) { if(NUMBER_CLASS.isAssignableFrom(formal)) { diff --git a/freemarker/src/freemarker/ext/beans/MethodUtilities.java b/freemarker/src/freemarker/ext/beans/MethodUtilities.java index d80efc1..97e810f 100644 --- a/freemarker/src/freemarker/ext/beans/MethodUtilities.java +++ b/freemarker/src/freemarker/ext/beans/MethodUtilities.java @@ -64,6 +64,11 @@ import freemarker.template.utility.UndeclaredThrowableException; class MethodUtilities { + static final Class WILDCARD_CLASS = new Object() { + public String toString() { + return "<fm-wildcard>"; + } + }.getClass(); static final Class OBJECT_CLASS = Object.class; private static final Method METHOD_IS_VARARGS = getIsVarArgsMethod(Method.class); private static final Method CONSTRUCTOR_IS_VARARGS = getIsVarArgsMethod(Constructor.class);