Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
2.2.2, 2.3.2
-
None
-
None
Description
Since the upgrade to groovy 2.2 GStringTemplate fails to execute the folowing template text:
<% myClosure = { param-> return "myClosure["+otherClosure(param)+"]"; } otherClosure = { param -> return "otherClosure["+param+"]"; } %> <%=myClosure("truc")%>
With the following stacktrace:
groovy.lang.MissingMethodException: No signature of method: groovy.lang.Binding.myClosure() is applicable for argument types: (java.lang.String) values: [truc] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:78) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) at groovy.tmp.templates.GStringTemplateScript1$_getTemplate_closure1.doCall(GStringTemplateScript1.groovy:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:622) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909) at groovy.lang.Closure.call(Closure.java:423) at groovy.lang.Closure$WritableClosure.writeTo(Closure.java:853) at groovy.lang.Closure$WritableClosure.toString(Closure.java:979) ...
Prefixing both closure declaration with "def" keyword "solves" the issue however it requires to review all templates and to reorder definitions