Class ObjectUtil

java.lang.Object
org.apache.groovy.runtime.ObjectUtil

@Deprecated public class ObjectUtil extends Object
Deprecated.
retained only so Groovy 4 compiled bytecode keeps linking; not emitted by any current transform and not intended for direct use
Binary-compatibility facade for class files compiled by Groovy 4.0.5+ (GROOVY-12257).

The @Immutable transform in Groovy 4.0.5 through 4.0.x emitted INVOKESTATIC calls to cloneObject(Object) into generated constructors and getters for defensive copies (GROOVY-10747). The original class was removed together with the $getLookup machinery it relied on (GROOVY-10931), which broke such pre-compiled classes with a NoClassDefFoundError at first instantiation. This facade restores the call target with equivalent behaviour, minus the lookup dependency: arrays are cloned via ArrayUtil exactly as before, and other Cloneables through their public clone() via the MOP.

Nothing compiled by Groovy 5+ references this class; its transforms emit invokedynamic-based or InvokerHelper clone calls instead.

Since:
4.0.5
  • Method Details

    • cloneObject

      public static <T> T cloneObject(T object) throws Throwable
      Deprecated.
      Clone the specified object
      Type Parameters:
      T - the object type
      Parameters:
      object - the object to clone
      Returns:
      the cloned object
      Throws:
      Throwable - some exception or error
      Since:
      4.0.5