You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by "Milles, Eric (TR Technology & Ops)" <er...@thomsonreuters.com> on 2018/09/14 15:54:53 UTC

Help with traits compilation

Groovy devs,
I am looking into these issues: https://github.com/groovy/groovy-eclipse/issues/714  https://github.com/grails/grails-testing-support/issues/31

When grails.testing.services.ServiceUnitTest is compiled, it produces the following class files in the build directory:
- ServiceUnitTest.class
- ServiceUnitTest$Trait$FieldHelper.class
- ServiceUnitTest$Trait$Helper.class
- ServiceUnitTest$Trait$Helper$_mockArtefact_closure1.class
- ServiceUnitTest$Trait$Helper$_mockArtefact_closure1$_closure2.class

However, the javap output of the class tells a different story with regards to inner types:
    SourceFile: "ServiceUnitTest.groovy"
    InnerClasses:
         public static abstract #19= #18 of #2; //Helper=class grails/testing/services/ServiceUnitTest$Trait$Helper of class grails/testing/services/ServiceUnitTest
         public static #22= #21 of #2; //FieldHelper=class grails/testing/services/ServiceUnitTest$Trait$FieldHelper of class grails/testing/services/ServiceUnitTest
         static #25= #24 of #2; //1=class grails/testing/services/ServiceUnitTest$Trait$FieldHelper$1 of class grails/testing/services/ServiceUnitTest

It is this last type -- ServiceUnitTest$Trait$FieldHelper$1 -- that cannot be resolved.  Can someone familiar with traits compilation say if this class belongs in the bytecode and therefore should also be one of the output class files?  Or if this is an errant entry in the class file?  When the Compiler/IDE tries to resolve the type, it of course gets an error since it is missing.

Eric M.