Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.7, 2.4.3
-
jvm 1.7, MaxOSX
Description
this fails:
def aWithB = new ClassA().withTraits(traitB)
when traitB is not from the classloader of class A.
full example code:
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() } }
Attachments
Attachments
Issue Links
- links to