Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

AST Transformations

Groovy provides many metaprogramming hooks for changing the runtime behavior of classes and objects. In addition, it provides hooks into Groovy's compilation process so that you can make changes to the language at compile time. These hooks are done through a mechanism called AST Transformations (sometimes refered to as macros in other languages).

The hook for accessing this capability is via annotations. In your Groovy code you will make use of one of more annotations. Behind the scenes, an AST processor relevant to the annotation you are using is inserted into the compiler phases at the appropriate point. You can explore some of the more popular Annotations below:

Implementing your own AST Transformations

There are two kinds of AST Transformations: local and global transformations:

  • No labels