freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [33/35] incubator-freemarker git commit: 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 impl
Date Wed, 30 Dec 2015 18:11:53 GMT
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.)


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/3a62ff8e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/3a62ff8e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/3a62ff8e

Branch: refs/heads/2.3
Commit: 3a62ff8ecfc63bec8c43d4996ffa5839b9871a9e
Parents: 957264e
Author: ddekany <ddekany@apache.org>
Authored: Tue Dec 29 19:29:52 2015 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Tue Dec 29 19:29:52 2015 +0100

----------------------------------------------------------------------
 .../core/BuiltInsForMultipleTypes.java          |  7 ++-
 src/main/java/freemarker/core/Environment.java  |  4 +-
 .../java/freemarker/template/Configuration.java |  5 ++
 src/manual/en_US/book.xml                       | 49 ++++++++++++++++++--
 .../expected/type-builtins-ici-2.3.24.txt       | 15 ++++++
 .../freemarker/test/templatesuite/testcases.xml |  5 +-
 6 files changed, 78 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3a62ff8e/src/main/java/freemarker/core/BuiltInsForMultipleTypes.java
----------------------------------------------------------------------
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 @@ class BuiltInsForMultipleTypes {
         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;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3a62ff8e/src/main/java/freemarker/core/Environment.java
----------------------------------------------------------------------
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 @@ import freemarker.template.utility.UndeclaredThrowableException;
  * {@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 @@ public final class Environment extends Configurable {
         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;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3a62ff8e/src/main/java/freemarker/template/Configuration.java
----------------------------------------------------------------------
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 @@ public class Configuration extends Configurable implements Cloneable,
ParserConf
      *          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>

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3a62ff8e/src/manual/en_US/book.xml
----------------------------------------------------------------------
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 @@ Sorted by name.last:
               <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 @@ Sorted by name.last:
               <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 @@ TemplateModel x = env.getVariable("x");  // get variable x</programlisting>
 
             <listitem>
               <para><literal>&lt;@</literal> and <literal>&lt;/@</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>&lt;#list <replaceable>...</replaceable>&gt;</literal>
+              to fail among others. (They shouldn't implement either, but this
+              is historical heritage.)</para>
+            </listitem>
           </itemizedlist>
         </section>
 
@@ -27448,6 +27474,23 @@ TemplateModel x = env.getVariable("x");  // get variable x</programlisting>
             </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>&lt;#list <replaceable>...</replaceable>&gt;</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>

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3a62ff8e/src/test/resources/freemarker/test/templatesuite/expected/type-builtins-ici-2.3.24.txt
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3a62ff8e/src/test/resources/freemarker/test/templatesuite/testcases.xml
----------------------------------------------------------------------
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" />


Mime
View raw message