GROOVY-12257: Restore ObjectUtil as a binary-compatibility facade for… - #2788
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2788 +/- ##
==================================================
+ Coverage 70.1064% 70.1276% +0.0212%
- Complexity 35774 35799 +25
==================================================
Files 1561 1562 +1
Lines 132373 132400 +27
Branches 24332 24345 +13
==================================================
+ Hits 92802 92849 +47
+ Misses 31170 31156 -14
+ Partials 8401 8395 -6
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
… Groovy 4 compiled @immutable classes The @immutable transform in Groovy 4.0.5 through 4.0.x (GROOVY-10747) emitted references to org.apache.groovy.runtime.ObjectUtil.cloneObject into generated constructors and getters for defensive copies. The class was removed along with the $getLookup machinery it relied on (GROOVY-10931), so such pre-compiled classes fail on Groovy 5+ with NoClassDefFoundError at first instantiation — only when a clone path actually executes, which for collection properties depends on the runtime value being Cloneable, making the failure intermittent. Restore the class as a deprecated facade with the original semantics minus the lookup dependency: null passes through, non-Cloneables throw CloneNotSupportedException, arrays clone via the unchanged ArrayUtil fast paths, and other Cloneables clone through their public clone() via the MOP (guarded by the same getMethod check as the original, so a non-public clone() still surfaces NoSuchMethodException). Nothing compiled by Groovy 5+ references the class; current transforms emit indy or InvokerHelper clone calls instead. Verified against real Groovy 4.0.33 bytecode: the reproducer's List property shape and the unconditional array/getter shape both fail with NoClassDefFoundError before this change and pass with it, preserving defensive-copy semantics.
paulk-asert
force-pushed
the
groovy12257
branch
from
August 15, 2026 20:38
68cb0f3 to
10b3130
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… Groovy 4 compiled @immutable classes
The @immutable transform in Groovy 4.0.5 through 4.0.x (GROOVY-10747) emitted references to org.apache.groovy.runtime.ObjectUtil.cloneObject into generated constructors and getters for defensive copies. The class was removed along with the $getLookup machinery it relied on (GROOVY-10931), so such pre-compiled classes fail on Groovy 5+ with NoClassDefFoundError at first instantiation — only when a clone path actually executes, which for collection properties depends on the runtime value being Cloneable, making the failure intermittent.
Restore the class as a deprecated facade with the original semantics minus the lookup dependency: null passes through, non-Cloneables throw CloneNotSupportedException, arrays clone via the unchanged ArrayUtil fast paths, and other Cloneables clone through their public clone() via the MOP (guarded by the same getMethod check as the original, so a non-public clone() still surfaces NoSuchMethodException). Nothing compiled by Groovy 5+ references the class; current transforms emit indy or InvokerHelper clone calls instead.
Verified against real Groovy 4.0.33 bytecode: the reproducer's List property shape and the unconditional array/getter shape both fail with NoClassDefFoundError before this change and pass with it, preserving defensive-copy semantics.