title: Groovy : Class.forName().newInstance() error
body: <p>I have this following method in which I return a <code>List&lt;ImField&gt;</code> object using the <code>List&lt;GPathResult&gt; filteredList</code>. I perform <code>filteredList.each</code> closure where I generate
  class at runtime and assign it a static type of <code>ImField</code>.</p>
  <pre><code>static List&lt;ImField&gt; getFields(GPathResult root,String fieldClass, String fieldType){
          List&lt;GPathResult&gt; filteredList = root.children().findAll{
              XMLSlurperUtil.name(it as GPathResult) == fieldType
          } as List&lt;GPathResult&gt;
          List&lt;ImField&gt; fields = []
          filteredList.each{GPathResult it,  int index -&gt;
              fields.add(Class.forName(fieldClass).newInstance() as ImField)
              fields[index].set(it)
          }
          fields
  }
  
  </code></pre>
  <p>The function call would look like so :</p>
  <pre><code>ImStageUtil.getFields(root, ImFieldFactory.SOURCE_FIELD, ImParserConstants.SOURCE_FIELD)
  </code></pre>
  <p>where <code>ImFieldFactory.SOURCE_FIELD = &quot;com.dto.fields.SourceField&quot;</code>
  and <code>ImParserContants.SOURCE_FIELD = &quot;SOURCEFIELD&quot;</code></p>
  <p>the error occurs at the <code>.each</code> closure line:</p>
  <pre><code>No signature of method: com.extractor.ImStageUtil$_getFields_closure11.doCall() is applicable for argument types: (groovy.util.slurpersupport.NodeChild) values: []
  Possible solutions: doCall(groovy.util.slurpersupport.GPathResult, int), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
  groovy.lang.MissingMethodException: No signature of method: com.extractor.ImStageUtil$_getFields_closure11.doCall() is applicable for argument types: (groovy.util.slurpersupport.NodeChild) values: []
  Possible solutions: doCall(groovy.util.slurpersupport.GPathResult, int), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
  </code></pre>