:source-highlighter: pygments
:pygments-style: emacs
:icons: font

[width="80%",align="center"]
|===
a| NOTE: _WARNING:_
Material on this page is still under development! We are currently releasing alpha versions of Groovy 4.0 with a goal
of gathering feedback on the language changes from our community. In addition, the beta versions assist other projects
and tool vendors within the Groovy ecosystem to begin assessing the impact of moving to/supporting Groovy 4.0.
Caution should be exercised if using new features as the details may change before final release.
|===

[[Groovy4.0old-parser]]
== Old parser removal

In Groovy 4.0, the old Antlr2 based parser is removed. Please use Groovy versions up to 3.x if you require the old parser.

[[Groovy4.0indy]]
== Classic bytecode generation removal

For many versions, Groovy could generate classic _call-site based_ bytecode
or bytecode targetting the JDK7+ invoke dynamic ("indy") bytecodes.
In Groovy 4.0, only bytecode using the latter approach can be generated.
Consequently, there are no longer any "-indy" jars.

Currently, the Groovy runtime still contains any necessary support for
classes compiled using older versions of Groovy.
Please use Groovy versions up to 3.x if you need to generate old bytecode.

[[Groovy4.0maven-coordinates]]
== Maven coordinates

In Groovy 4.0, the _groupId_ of the maven coordinates for Groovy have changed from `org.codehaus.groovy`
to `org.apache.groovy`. Please update your Gradle/Maven/other build settings appropriately.

[[Groovy4.0other]]
== Other improvements

=== GString performance improvements

* GString internals were revamped to improve performance.
In numerous cases, GString data structures are automatically cached.
While rarely used, GStrings do permit their internal data structures to
be viewed (and even changed!). In such circumstances, caching is disabled.
If you wish to view and not change the internal data structures, you can
call a `freeze()` method in `GStringImpl` to disallow changing of the internal
data structures which allows caching to remain active.
link:https://issues.apache.org/jira/browse/GROOVY-9637[GROOVY-9637]

=== JavaShell (incubating)

A Java equivalent of GroovyShell, allowing to more easily work with snippets of Java code.

=== JSR308 improvements (work in progress)

Groovy has been improving JSR-308 support over recent versions.
In Groovy 4.0, additional support has been added.

=== Java-inspired changes (under investigation)

The following changes are being explored:

* Switch expressions
* Module definitions written in Groovy
* Support for records

== Other breaking changes

* Numerous classes previously "leaked" ASM constants which are essentially an internal implementation detail by virtue of
implementing an `Opcodes` interface. This will not normally affect the majority of
Groovy scripts but might impact code which manipulates AST nodes such as AST transforms.
Before compiling with Groovy 4, some of these may need one or more appropriate static import statements added.
AST transforms which extend `AbstractASTTransformation` are one example of potentially affected classes.
(link:https://issues.apache.org/jira/browse/GROOVY-9736[GROOVY-9736]).
* `ASTTest` previously had `RUNTIME` retention but now has `SOURCE` retention.
We know of no users making use of the old retention but are aware of various
issues keeping the old value.
link:https://issues.apache.org/jira/browse/GROOVY-9702[GROOVY-9702]
* There were some inconsistencies with JavaBean property naming conventions
for various edge cases, e.g. for a field with a name being a single uppercase `X` and having a `getX` accessor,
then the field was given priority over the accessor.
link:https://issues.apache.org/jira/browse/GROOVY-9618[GROOVY-9618]
* Numerous mostly internal data structure classes, e.g. AbstractConcurrentMapBase, AbstractConcurrentMap, ManagedConcurrentMap
were deprecated and their usage replaced with better alternatives.
This should be mostly invisible but some changes might impact users using
internal Groovy classes directly.
link:https://issues.apache.org/jira/browse/GROOVY-9631[GROOVY-9631]
* We bumped our Picocli version. This resulted in minor formatting changes
of some CLI help messages. We recommend not relying on the exact format of such messages.
link:https://issues.apache.org/jira/browse/GROOVY-9627[GROOVY-9627]
>>>>>>> c9e657d... fix typo

== JDK requirements

Groovy 4.0 requires JDK9+ to build and JDK8 is the minimum version of the JRE that we support.

[[Groovy4.0releasenotes-Moreinformation]]
== More information

You can browse all the link:../changelogs/changelog-4.0.0-unreleased.html[tickets closed for Groovy 4.0 in JIRA].
