Fork me on GitHub

Release notes for Groovy 2.5

(Material on this page is still under development!)

Macro support

With Groovy 2.5, you can write macros in Groovy!

Expressions and statements


Macro classes


AST matching


New AST Transformations

  • @AutoFinal

  • @AutoImplement allows you to provide dummy implementations of any abstract methods that might be inherited from super classes or interfaces (GROOVY-7860).

  • @ImmutableBase

  • @ImmutableOptions

  • @MapConstructor adds a Map-based constructor to a class. This allows a usage style similar to Groovy’s named parameters but doesn’t use the no-arg constructor and then call setters. This may be useful if you have final properties or wish the class file to have the Map constructor for integration purposes (GROOVY-7353).

  • @NamedDelegate

  • @NamedParam

  • @NamedParams

  • @NamedVariant

  • @PropertyOptions

  • @VisibilityOptions

AST Transformation improvements

  • @Canonical and @Immutable become meta-annotations allowing more flexible usage of the annotation attributes from its constituent annotations (GROOVY-6319).

  • @Immutable now supports Java’s Optional container class (GROOVY-7600) and handles inheritance hierarchies (GROOVY-7162).

  • @Delegate can now be used on getters (GROOVY-7769).

  • @TupleConstructor now supports pre and post closure conditions to match the functionality provided by @MapConstructor (GROOVY-7769).

  • @TupleConstructor and @Builder should be able to use defined setters rather than the field directly (GROOVY-7087).

  • Most annotations check property and field names provided to annotation attributes (GROOVY-7087).

Tool improvements

Some improvements were made to Groovysh shell and the Groovy Console:

  • groovysh should offer easier access to grapes (GROOVY-6514).

  • groovyconsole now provides an ASMifier tab within the AstBrowser (GROOVY-8091).

CliBuilder changes

  • Groovy’s CliBuilder now supports annotation style definitions (GROOVY-7825).

Other improvements

  • Repeated annotation support has been added

  • Alternative to with called tap that has an implicit return delegate (GROOVY-3976).

  • Various JSON customization options are now supported (GROOVY-6975 and GROOVY-6854).

  • Method parameter names are now accessible at runtime (GROOVY-7423).

Breaking changes

A few issues fixed might also be considered breaking changes in some situations:

  • @TupleConstructor could use the order of properties listed in 'includes' when that option is used (GROOVY-8016)

  • @ToString could output properties in a predefined order when 'includes' is used (GROOVY-8014)

  • AstNodeToScriptAdapter should output source using the recommended modifier order (GROOVY-7967)

  • ObjectRange iterator returns null instead of NoSuchElementException (GROOVY-7961)

  • IntRange iterator returns null instead of NoSuchElementException (GROOVY-7960) (GROOVY-7937)

  • o.c.g.r.t.DefaultTypeTransformation does not apply the right toString on primitive arrays when transforming to String (GROOVY-7853)

  • Remove synchronized methods of groovy.sql.Sql and document it as not thread-safe (GROOVY-7673)

  • InvokerHelper formatting methods have inconsistent API (GROOVY-7563)

  • Fix up transforms (apart from TupleConstructor) which are affected by empty includes default (GROOVY-7529)

  • TupleConstructor with empty includes includes all (GROOVY-7523)

  • TupleConstructor overwrites empty default constructors (GROOVY-7522)

  • ResourceGroovyMethods/NioGroovyMethods BOM behavior is inconsistent (GROOVY-7465)

  • API inconsistency between takeWhile, dropWhile and collectReplacements for CharSequences (GROOVY-7433)

  • @ToString could support non-field properties (GROOVY-7394)

  • same linkedlist code different behavior between groovy and java (GROOVY-6396)

  • CLONE - same linkedlist code different behavior between groovy and java (fix priority of DGM methods vs actual methods on an object)

  • Accessing private methods from public ones using categories and inheritance causes MissingMethodException (GROOVY-6263)

  • Have the elvis operator (?:) support the Optional type in Java 8 (GROOVY-6744)

  • java.util.Optional should evaluate to false if empty (GROOVY-7611)

  • If you use the FileSystemCompiler class programmatically (rather than via the groovyc commandline) and you use the part of it for handling commandline processing, then you might notice that it has been converted to picocli and usage of a handful of methods will throw a DeprecationException which mentions the alternative approach you should use.

JDK requirements changes

Groovy 2.5 requires JDK7+ to build and JDK7 is the minimum version of the JRE that we support.

More information

You can browse all the tickets closed for Groovy 2.5 in JIRA.