This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-website.git
The following commit(s) were added to refs/heads/asf-site by this push:
new accb56b additional notes for breaking changes
accb56b is described below
commit accb56b0fa9bd85f6f5f179727d86319748dfde1
Author: Paul King <[email protected]>
AuthorDate: Fri May 16 18:17:28 2025 +1000
additional notes for breaking changes
---
site/src/site/releasenotes/groovy-5.0.adoc | 104 +++++++++++++++++------------
1 file changed, 60 insertions(+), 44 deletions(-)
diff --git a/site/src/site/releasenotes/groovy-5.0.adoc
b/site/src/site/releasenotes/groovy-5.0.adoc
index 23547e5..247d7ee 100644
--- a/site/src/site/releasenotes/groovy-5.0.adoc
+++ b/site/src/site/releasenotes/groovy-5.0.adoc
@@ -589,7 +589,7 @@ A future release of Groovy may improve this
situation. It might provide aliases, like `map` for `collect`,
`filter` for `findAll`, etc. Alternatively, it might provide methods like
`collecting` for iterables and arrays. We are assessing usage of the current
-changes before offering those alternatives.
+changes before potentially offering such alternatives.
=== Additional array extensions
@@ -848,6 +848,46 @@ was changed to `Iterator<List>` from `List<List>`. This
facilitates calling a se
* There was a breaking change for an edge case involving nulls and the
"spread-dot" operator that shouldn't affect most users
(https://issues.apache.org/jira/browse/GROOVY-11453[GROOVY-11453])
* Consistency was improved for Map-based property access with respect to
visibility (https://issues.apache.org/jira/browse/GROOVY-11403[GROOVY-11403] and
https://issues.apache.org/jira/browse/GROOVY-11367[GROOVY-11367])
+* Visibility was tightened/aligned for package-private fields, properties and
methods (https://issues.apache.org/jira/browse/GROOVY-11357[GROOVY-11357])
+* In earlier versions of Groovy,
+the compiler was lenient when finding duplicate imports or an import
+and a similarly-named class definition.
+While having duplicates was considered _poor style_, the compiler followed the
+lenient behavior of letting the last definition "win", ignoring earlier
definitions.
+E.g. for two imports (Groovy 1-4):
++
+[source,groovy]
+----
+import java.util.Date
+import java.sql.Date
+
+println Date // => class java.sql.Date
+----
++
+or an import and a class definition (Groovy 1-4):
++
+[source,groovy]
+----
+import java.sql.Date
+class Date { }
+
+println Date // => class Date
+----
++
+or a regular import and an alias import (Groovy 1-4):
++
+[source,groovy]
+----
+import java.util.Date
+import java.util.Calendar as Date // don't do this!
+
+println Date // => class java.util.Calendar
+----
+From Groovy 5, the compiler now follows Java behavior and gives an error in
such cases
+(link:https://issues.apache.org/jira/browse/GROOVY-8254[GROOVY-8254]). A
slightly more
+lenient approach is taken when using `groovysh`. For the `groovysh` repl, a
newly entered
+import is deemed to override an old import with the same simple name,
+with the old import being discarded
(link:https://issues.apache.org/jira/browse/GROOVY-11224[GROOVY-11224]).
* Scripts containing a static `main` method and no statements outside that
method have changed slightly
for improved JEP 512 compatibility. The script class for such methods no
longer extends `Script` and
hence no longer has access to the script context or bindings. For many such
scripts, access to the
@@ -874,14 +914,21 @@ without a default value. If framework writers have made
use of,
or coded around the buggy behavior, they may need to rework their code.
It might mean simplification by removing a workaround.
(link:https://issues.apache.org/jira/browse/GROOVY-10862[GROOVY-10862])
-* Some Groovy AST transform annotations, like `@ToString` were given
+* Some Groovy AST transform annotations, like `@ToString`, `@AutoClone`, and
`@Sortable` were given
`RUNTIME` retention even though Groovy itself and typical Groovy user
behavior never needs access to that annotation at runtime. This was
done with a view that perhaps some future tools or framework might
be able to use that information in some useful way. We know of no such
frameworks or tools, so we have changed the retention to `SOURCE` to
-give cleaner class files.
-(link:https://issues.apache.org/jira/browse/GROOVY-10862[GROOVY-10862])
+give cleaner class files and reflect Groovy's use of those annotations.
+Annotation collectors like `@Immutable` (`RUNTIME` for legacy reasons),
+and `@Canonical` (`CLASS` for potential future tooling though not currently
stored)
+are also now `SOURCE` retention.
+(link:https://issues.apache.org/jira/browse/GROOVY-10855[GROOVY-10855])
+* Explicit `abstract` or `final` modifiers on an Enum definition were
previously
+ignored but now cause a compilation error. If you have used those modifiers,
remove them
+from your source files.
+(link:https://issues.apache.org/jira/browse/GROOVY-10811[GROOVY-10811])
* Groovy's `%` operator is called the "remainder" operator. Informally,
it is also known as the "mod" operator and indeed, for operator overloading
purposes we have historically used the `mod` method. While this name is in
@@ -891,52 +938,21 @@ our behavior, like Java's, follows the behavior of the
`remainder` method.
In Groovy 5, operator overloading for `%` is now handled by the `remainder`
method.
Fallback behavior is supported and workarounds exist for folks already using
the `mod` method.
(link:https://issues.apache.org/jira/browse/GROOVY-10800[GROOVY-10800])
+* It is now possible to create a custom class loader that extends
`GroovyClassLoader` which
+uses a different cache class for the source cache.
+Anyone doing this and relying on the specific type for the protected
`sourceCache` field should change their
+code to use the `FlexibleEvictableCache` interface type rather than the
previous hard-coded implementation class.
+(link:https://issues.apache.org/jira/browse/GROOVY-9742[GROOVY-9742])
+* Improvements have been made to include additional checking for captured
types.
+(link:https://issues.apache.org/jira/browse/GROOVY-9074[GROOVY-9074])
* Improvements have been made to better align how method selection
is performed between the dynamic Groovy runtime and with static compilation.
(link:https://issues.apache.org/jira/browse/GROOVY-8788[GROOVY-8788])
-* In earlier versions of Groovy,
-the compiler was lenient when finding duplicate imports or an import
-and a similarly-named class definition.
-While having duplicates was considered _poor style_, the compiler followed the
-lenient behavior of letting the last definition "win", ignoring earlier
definitions.
-E.g. for two imports (Groovy 1-4):
-+
-[source,groovy]
-----
-import java.util.Date
-import java.sql.Date
-
-println Date // => class java.sql.Date
-----
-+
-or an import and a class definition (Groovy 1-4):
-+
-[source,groovy]
-----
-import java.sql.Date
-class Date { }
-
-println Date // => class Date
-----
-+
-or a regular import and an alias import (Groovy 1-4):
-+
-[source,groovy]
-----
-import java.util.Date
-import java.util.Calendar as Date // don't do this!
-
-println Date // => class java.util.Calendar
-----
-From Groovy 5, the compiler now follows Java behavior and gives an error in
such cases
-(link:https://issues.apache.org/jira/browse/GROOVY-8254[GROOVY-8254]). A
slightly more
-lenient approach is taken when using `groovysh`. For the `groovysh` repl, a
newly entered
-import is deemed to override an old import with the same simple name,
-with the old import being discarded
(link:https://issues.apache.org/jira/browse/GROOVY-11224[GROOVY-11224]).
+* Improvements have been made when mixing `@TupleConstructor` and traits with
default values.
+(link:https://issues.apache.org/jira/browse/GROOVY-8219[GROOVY-8219],
* Improvements have been made to improve consistency when accessing fields
within Map-like classes.
(link:https://issues.apache.org/jira/browse/GROOVY-6144[GROOVY-6144],
link:https://issues.apache.org/jira/browse/GROOVY-5001[GROOVY-5001])
-* Visibility was tightened/aligned for package-private fields, properties and
methods (https://issues.apache.org/jira/browse/GROOVY-11357[GROOVY-11357])
[[Groovy5.0-requirements]]
== JDK requirements