paulk-asert opened a new pull request, #2789:
URL: https://github.com/apache/groovy/pull/2789

   … 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to