Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3294

Improved class loading for AST transformations

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.6-rc-1, 1.6-rc-2
    • 1.6-rc-3, 1.7-beta-1
    • Compiler
    • None
    • Patch

    Description

      Currently, groovyc loads AST transformations with the same class loader that is also responsible for loading compile dependencies. This can lead to problems for compiler clients that provide a custom class loader for loading compile dependencies, as such a class loader might not be able to meet the requirements for loading AST transformations. The most prominent example is GMaven, which uses a custom class loader to prevent classpath pollution without having to fork groovyc. Unfortunately this also means that GMaven cannot compile any programs that make use of AST transformations.
      This patch allows for compiler clients to optionally provide a separate class loader for loading AST transformations, thereby decoupling the class loading of AST transformations from that of compile dependencies. This makes it possible for compiler clients such as GMaven (and possibly Gradle) to support AST transformations, and paves the way for further class loading improvements in future versions of groovyc.
      The patch is fairly small and tries to keep changes to the existing codebase to an absolute minimum. Apart from applying moderate changes to two transform-related classes, it only adds a few lines of code to class CompilationUnit. Existing compiler clients will see no change in behavior. Please consider this patch for inclusion in Groovy 1.6, or a 1.6 maintenance release. Also attached is the corresponding GMaven patch. Any feedback is welcome.

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              pniederw Peter Niederwieser
              Votes:
              4 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: