What’s next for the Groovy language: The 2018 roadmap

The JVM stalwart will support Java 9 modularity and Java 8 lambda capabilities, and now provides a new macro capability

What’s next for the Groovy language: The 2018 roadmap
Garry Knight (CC BY 2.0)

Groovy, the veteran language for the Java Virtual Machine, has several enhancements on its roadmap, such as to support Java 9 modularity and Java 8 lambda capabilities. Although closely linked to Java, Groovy offers additional capabilities such as the ability to write compile-time transformations and macros.

The Apache Software Foundation plans the following Groovy upgrades in the next year:

  • Versions 2.5 is now available for Java 7 and later.
  • Version 2.6 and 3.0, both set to arrive in about a year, and both currently available in alpha releases. Version 2.6 is aimed at Java 7 users, and Version 3.0 at Java 8 and 9 users; their capabitiies will be similar.

Where to download Groovy

You can download the various versions of Groovy from the project’s Bintray repository.

Planned Groovy 3.0 features

When Groovy 3.0 is released, you can expect the following additions and enhancements:

  • Groovy 3.0 will add support for Java 8 lambda syntax and method references.
  • Users will be able to run Groovy with the Java 9 JVM without getting warnings about features possibly not being supported.
  • Groovy can be invoked as a module on the JVM, using the Java 9 module path instead of the traditional classpath, which has not been set up to work with modules. The level of support for this capability is still being determined.
  • A more-flexible parser, called Parrot, supports additional syntax and language features.
  • Java’s class do/while loop, to ensure execution of a block of statements, is supported.
  • A macro capability expands the options for building compile-time transformations.
  • Java-style array initialization is added.
  • New operators for capabilities such as identity comparison are added.

Groovy 2.6 will have similar capabilities for Java 7 users.

New Groovy 2.5 features

Groovy 2.5 adds macro support that makes it easier to use the language’s extensible compilation process. With macros, developers can use Groovy’s syntax directly instead of using internal compiler representations when building compile-time metaprogramming extensions. Developers no longer need to be familiar with the compiler’s internal representations of syntactic structures to write AST transformations used in compilation.

Groovy 2.5 requires Java Development Kit (JDK) 8 or a later version to build. JDK 7 is the minimum version of the Java Runtime Environment (JRE) supported by Groovy 2.5.

Groovy 2.5 also includes improvements for tools and AST transformations:

  • groovy and groovyConsole now run JUnit 5 tests directly.
  • The Groovy CLIBuilder tool, to help process command-line arguments, now supports annotation style definitions. Also, revamped versions of CLIBuilder now support Commons CLI and Picocli-backed parser implementations.
  • Repeated annotation.
  • Various JSON customizations.
  • Names for method parameters now are accessible at runtime, a capability also supported in JDK 8.
  • For AST transformations, @Canonical is now a meta-annotation, which allows for more flexible usage of annotation attributes from constituent annotations. Developers also can define a custom meta-annotation.
  • @Canonical expands into the @TupleConstructor@EqualsAndHashCode, and @ToString annotations, with annotation attributes distributed to component annotations that support them.

There are some known issues in Groovy 2.5, including:

  • JDK 9 and later versions produce warnings with many libraries, including Groovy, due to planned future restrictions in the JDK. Parts of Groovy are to be reengineered to remove or reduce these warnings.
  • Users who need the groovy-xml module and who run JDK9 or later may need to use the --add-modules java.xml.bind command-line option to fix the break in backward compatibility.

Copyright © 2018 IDG Communications, Inc.