Bug fixed: With incompatible_improvements set to 2.3.24, m?is_sequence doesn't return true for Java methods wrapped by BeansWrapper and its subclasses (most notably DefaultObjectWrapper) anymore, as they only implement the [index] operator, but not ?size, which causes <#list ...> to fail among others. (They shouldn't implement either, but this is historical heritage.)
diff --git a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java b/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
index 861b370..81bcf59 100644
--- a/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
+++ b/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
@@ -436,7 +436,12 @@
TemplateModel _eval(Environment env) throws TemplateException {
TemplateModel tm = target.eval(env);
target.assertNonNull(tm, env);
- return (tm instanceof TemplateSequenceModel) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
+ return (tm instanceof TemplateSequenceModel
+ && (
+ !(tm instanceof OverloadedMethodsModel || tm instanceof SimpleMethodModel)
+ || !env.isIcI2324OrLater())
+ )
+ ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
}
}
diff --git a/src/main/java/freemarker/core/Environment.java b/src/main/java/freemarker/core/Environment.java
index 5ae1bf7..3d61aaa 100644
--- a/src/main/java/freemarker/core/Environment.java
+++ b/src/main/java/freemarker/core/Environment.java
@@ -92,7 +92,7 @@
* {@link Template#createProcessingEnvironment(Object rootMap, Writer out, ObjectWrapper wrapper)}
*/
public final class Environment extends Configurable {
-
+
private static final ThreadLocal threadEnv = new ThreadLocal();
private static final Logger LOG = Logger.getLogger("freemarker.runtime");
@@ -2779,7 +2779,7 @@
return configuration.getIncompatibleImprovements().intValue() < _TemplateAPI.VERSION_INT_2_3_22;
}
- private boolean isIcI2324OrLater() {
+ boolean isIcI2324OrLater() {
return configuration.getIncompatibleImprovements().intValue() >= _TemplateAPI.VERSION_INT_2_3_24;
}
diff --git a/src/main/java/freemarker/template/Configuration.java b/src/main/java/freemarker/template/Configuration.java
index 8be37db..82c46b3 100644
--- a/src/main/java/freemarker/template/Configuration.java
+++ b/src/main/java/freemarker/template/Configuration.java
@@ -780,6 +780,11 @@
* it's executed in the main namespace, but that haven't happened when the imported template was already
* imported earlier in another namespace.
* </li>
+ * <li><p>
+ * {@code ?is_sequence} doesn't return {@code true} for Java methods wrapped by {@link BeansWrapper} and
+ * its subclasses (most notably {@link DefaultObjectWrapper}) anymore, as they only implement the
+ * {@code [index]} operator, but not {@code ?size}, which causes {@code <#list ...>} to fail among others.
+ * (They shouldn't implement either, but this is historical heritage.)
* </ul>
* </li>
* </ul>
diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml
index 145eb3c..8f43a97 100644
--- a/src/manual/en_US/book.xml
+++ b/src/manual/en_US/book.xml
@@ -17886,7 +17886,13 @@
<tr>
<td><literal>is_sequence</literal></td>
- <td>sequence</td>
+ <td>sequence (Historical quirk: Before <link
+ linkend="pgui_config_incompatible_improvements_how_to_set"><literal>incompatible_improvements</literal></link>
+ 2.3.24 it returns <literal>true</literal> for Java methods as
+ they implement the
+ <literal>[<replaceable>index</replaceable>]</literal>
+ operator, however, they fail on
+ <literal>?size</literal>.)</td>
</tr>
<tr>
@@ -17911,7 +17917,10 @@
<tr>
<td><literal>is_indexable</literal></td>
- <td>sequence</td>
+ <td>sequence (Historical quirk: it returns
+ <literal>true</literal> for Java methods as they implement the
+ <literal>[<replaceable>index</replaceable>]</literal>
+ operator.)</td>
</tr>
<tr>
@@ -26553,11 +26562,28 @@
<listitem>
<para><literal><@</literal> and <literal></@</literal> is
- now allowed in String literals that contain
+ now allowed in string literals that contain
<literal>${<replaceable>exp</replaceable>}</literal>, and will
be part of the literal as is. Earlier it was a syntactical
error.</para>
</listitem>
+
+ <listitem>
+ <para>Bug fixed: With
+ <literal>incompatible_improvements</literal> set to 2.3.24
+ (<link linkend="topic.defaultObjectWrapperIcI">see how
+ here...</link>),
+ <literal><replaceable>m</replaceable>?is_sequence</literal>
+ doesn't return <literal>true</literal> for Java methods wrapped
+ by <literal>BeansWrapper</literal> and its subclasses (most
+ notably <literal>DefaultObjectWrapper</literal>) anymore, as
+ they only implement the
+ <literal>[<replaceable>index</replaceable>]</literal> operator,
+ but not <literal>?size</literal>, which causes
+ <literal><#list <replaceable>...</replaceable>></literal>
+ to fail among others. (They shouldn't implement either, but this
+ is historical heritage.)</para>
+ </listitem>
</itemizedlist>
</section>
@@ -27448,6 +27474,23 @@
</listitem>
<listitem>
+ <para>Bug fixed: With
+ <literal>incompatible_improvements</literal> set to 2.3.24
+ (<link linkend="topic.defaultObjectWrapperIcI">see how
+ here...</link>),
+ <literal><replaceable>m</replaceable>?is_sequence</literal>
+ doesn't return <literal>true</literal> for Java methods wrapped
+ by <literal>BeansWrapper</literal> and its subclasses (most
+ notably <literal>DefaultObjectWrapper</literal>) anymore, as
+ they only implement the
+ <literal>[<replaceable>index</replaceable>]</literal> operator,
+ but not <literal>?size</literal>, which causes
+ <literal><#list <replaceable>...</replaceable>></literal>
+ to fail among others. (They shouldn't implement either, but this
+ is historical heritage.)</para>
+ </listitem>
+
+ <listitem>
<para>Added an overload to
<literal>Configuration.getSupportedBuiltInNames</literal> and
<literal>Configuration.getSupportedBuiltInDirectiveNames</literal>
diff --git a/src/test/resources/freemarker/test/templatesuite/expected/type-builtins-ici-2.3.24.txt b/src/test/resources/freemarker/test/templatesuite/expected/type-builtins-ici-2.3.24.txt
new file mode 100644
index 0000000..b96f6f9
--- /dev/null
+++ b/src/test/resources/freemarker/test/templatesuite/expected/type-builtins-ici-2.3.24.txt
@@ -0,0 +1,15 @@
+StNuBoMeTaMaHaHxSeCoCxEnInDiNo
+1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 1 0 0 0 0 0 0 0 0 1 0
+0 0 0 0 0 1 0 0 0 0 0 0 0 1 0
+0 0 0 0 0 0 1 1 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 1 0 0 1 1 0 0
+0 0 0 0 0 0 0 0 0 1 0 1 0 0 0
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
+1 0 0 0 0 0 1 1 0 0 0 0 0 0 0
+0 0 0 1 0 0 0 0 0 0 0 0 1 0 0
+0 0 0 1 0 0 0 0 0 0 0 0 1 0 0
diff --git a/src/test/resources/freemarker/test/templatesuite/testcases.xml b/src/test/resources/freemarker/test/templatesuite/testcases.xml
index 31d6606..4a6e539 100644
--- a/src/test/resources/freemarker/test/templatesuite/testcases.xml
+++ b/src/test/resources/freemarker/test/templatesuite/testcases.xml
@@ -186,7 +186,10 @@
<setting incompatible_improvements="min, 2.3.20"/>
</testCase>
<testCase name="type-builtins[#endTN]-ici-2.3.21">
- <setting incompatible_improvements="2.3.21, max"/>
+ <setting incompatible_improvements="2.3.21, 2.3.23"/>
+ </testCase>
+ <testCase name="type-builtins[#endTN]-ici-2.3.24">
+ <setting incompatible_improvements="2.3.24, max"/>
</testCase>
<testCase name="date-type-builtins" noOutput="true" />
<testCase name="url" noOutput="true" />