[ https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14638895#comment-14638895 ]
Jochen Kemnade edited comment on GROOVY-7074 at 7/23/15 2:21 PM: ----------------------------------------------------------------- No, the metaclass doesn't seem to change, at lest it's the same before and after the script's execution. I think the reason is that for a Builder (and any other object that overrides {{groovy.lang.GroovyObjectSupport.invokeMethod(String, Object)}}), we need to invoke the {{invokeMethod}} method on the Builder itself and not on the metaClass. {{InvokerHelper#invokePogoMethod}} does that in line 920 (2.4.4). was (Author: jkemnade): No, the metaclass doesn't seem to change, at lest it's the same before and after the script's execution. I think the reason is that for a Builder, we need to invoke the {{invokeMethod}} method on the Builder itself and not on the metaClass. {{InvokerHelper#invokePogoMethod}} does that in line 920 (2.4.4). > DelegatingScript does not work with Builder as delegate > ------------------------------------------------------- > > Key: GROOVY-7074 > URL: https://issues.apache.org/jira/browse/GROOVY-7074 > Project: Groovy > Issue Type: Bug > Components: GroovyScriptEngine > Affects Versions: 2.4.0-beta-3 > Environment: Windows 7, Linux Mint 16 Petra > Reporter: Tobias Schulte > Labels: patch-available > Attachments: > 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch > > > DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder > instance. > import org.codehaus.groovy.control.CompilerConfiguration > import groovy.xml.MarkupBuilder > def cc = new CompilerConfiguration() > cc.scriptBaseClass = DelegatingScript.class.name > def sh = new GroovyShell(new Binding(), cc) > def script = sh.parse(''' > foo { > bar() > } > ''') > def markupBuilder = new MarkupBuilder() > script.setDelegate(markupBuilder) > script.run() > does throw a groovy.lang.MissingMethodException. If I change the script to > delegate.foo { > bar() > } > it works. -- This message was sent by Atlassian JIRA (v6.3.4#6332)