[ https://issues.apache.org/jira/browse/GROOVY-7443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14574702#comment-14574702 ]
ASF GitHub Bot commented on GROOVY-7443: ---------------------------------------- GitHub user dkobylarz opened a pull request: https://github.com/apache/incubator-groovy/pull/34 GROOVY-7443: traits classloaders support GROOVY-7443: traits classloaders support You can merge this pull request into a Git repository by running: $ git pull https://github.com/vital-ai/incubator-groovy master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-groovy/pull/34.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #34 ---- commit 2328a026ead10203d988a85dda444b147db553d0 Author: hadfield <m...@vital.ai> Date: 2015-06-02T13:11:23Z crude classloader test commit d9e7110ebeda2194177303e536b0d3a220566103 Author: Dariusz Kobylarz <darek.kobyl...@gmail.com> Date: 2015-06-02T14:17:43Z clean dynamic trait classloader code commit 460bbe9bdc5bb45e7ec31b220abbd7870e79da51 Author: Dariusz Kobylarz <darek.kobyl...@gmail.com> Date: 2015-06-05T14:22:40Z Merge remote-tracking branch 'upstream/master' commit 499fd92b36e0207689eec28b20497876ddf228aa Author: Dariusz Kobylarz <darek.kobyl...@gmail.com> Date: 2015-06-05T15:39:54Z GROOVY-7443: traits classloaders support ---- > instantiating a class withTraits does not use the classloader of the trait > -------------------------------------------------------------------------- > > Key: GROOVY-7443 > URL: https://issues.apache.org/jira/browse/GROOVY-7443 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime > Affects Versions: 2.3.7, 2.4.3 > Environment: jvm 1.7, MaxOSX > Reporter: Marc Hadfield > Labels: class-generation, traits, usertask > Attachments: GroovyTraitsClassloaderTest.groovy > > > this fails: > def aWithB = new ClassA().withTraits(traitB) > when traitB is not from the classloader of class A. > full example code: > {code:Java} > package groovy.lang.traits > import org.codehaus.groovy.control.CompilerConfiguration; > class GroovyTraitsClassloaderTest { > static class ClassA { > > } > > static trait TraitA { > > def aMethod() { > println "traitA method" > } > > } > > static main(args) { > > > def aWithA = new ClassA().withTraits(TraitA) > > aWithA.aMethod() > > > GroovyClassLoader gcl = new > GroovyClassLoader(Thread.currentThread().getContextClassLoader()); > > Class classB = gcl.parseClass("""\ > class ClassB {} > """) > > Class traitB = gcl.parseClass("""\ > trait TraitB { > > def bMethod() { > println "traitB method" > } > > } > """) > > //ok > def bWithA = classB.newInstance().withTraits(TraitA) > //ok > def bWithB = classB.newInstance().withTraits(traitB) > bWithB.bMethod() > > //fails > def aWithB = new ClassA().withTraits(traitB) > > aWithB.bMethod() > > > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)