Workaround to "startup failed: General error during class generation: Method too large" error for service

<iterate> generates the body of the loop twice for maps or map-like objects…once for Map and once for Collection<Map.Entry> (it tests if it is an instance of either, but generates the body of the loop for both).

If you have nested maps, every iterate inside it increases this by another factor of 2, so a block of 4 nested iterates would generate the fairly short XML section to something 16x as large in groovy.

It doesn’t take much nesting to get a “Method too large” compilation error.

But, changing something like this:

<iterate list=“xMap” key=“xKey” entry=“xValue”>

To this:

<set field=“xMapKeySet” from=“xMap.keySet()”/>
<iterate list=“xMapKeySet” entry=“xKey”>
<set field=“xValue” from=“xMap[xKey]”/>

Removes the doubling in the generated groovy. Perhaps this has been addressed in a later version, as I am not running the latest, but in case it hasn’t…or if you run into the issue, this gets around the “Method too large” issue.

1 Like