title: freemarker test for list and iterate it
body: <p>I have a data element that can either be a Map or a List of Maps.</p>
  
  <p>Here are two simplified data examples (expressed as JSON for readability) </p>
  
  <p>1) Maps</p>
  
  <pre><code>{
      "lom:general": {
          "lom:title": {"lom:string": {
              "language": "fr",
              "content": "Premiers Pas avec un Progiciel de Gestion Intégré"
          }},
          "lom:language": "fr"
      },
      "lom:technical": {"lom:location": "http://hub11.ecolearning.eu/course/progiciel-metiers-pgi/"}
  }
  </code></pre>
  
  <p>2) List of Maps</p>
  
  <pre><code>{
      "lom:general": {
          "lom:title": {"lom:string": [
              {
                  "language": "fr",
                  "content": "DIY Education aux médias et à l'information - 3ed"
              },
              {
                  "language": "en",
                  "content": "DIY Media and Information Literacy - 3ed"
              }
          ]},
          "lom:language": [
              "fr",
              "en"
          ]
      },
      "lom:technical": {"lom:location": "http://hub5.ecolearning.eu/course/diy-do-it-yourself/"}
  }
  </code></pre>
  
  <p>I want to check the type of element lom:general.lom:title.lom:string and iterate it if it is a list.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>&lt;title&gt;
      &lt;#assign titles = lom\:general.lom\:title.lom\:string&gt;
      &lt;#if titles?is_enumerable&gt;
          &lt;#list titles as title&gt;
              &lt;string language="${title.language}"&gt;${title.content}&lt;/string&gt;
          &lt;/#list&gt;
      &lt;#else&gt;
          &lt;string language="${titles.language}"&gt;${titles.content}&lt;/string&gt;
      &lt;/#if&gt;
  &lt;/title&gt;
  </code></pre>
  
  <p>The template works as expected with the first data example. However, the second data example raises a StackOverflowError</p>
  
  <pre><code>java.lang.StackOverflowError
  at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:188)
  at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:164)
  at sun.reflect.generics.reflectiveObjects.TypeVariableImpl.getGenericDeclaration(TypeVariableImpl.java:164)
  at sun.reflect.generics.reflectiveObjects.TypeVariableImpl.equals(TypeVariableImpl.java:189)
  at com.sun.beans.TypeResolver.resolve(TypeResolver.java:190)
  at com.sun.beans.TypeResolver.resolve(TypeResolver.java:201)
  </code></pre>
  
  <p>Where the last line is repeated dozens of times</p>