Skip to content

Improve configuration cache support for Java Object Serialization #13588

@bamboo

Description

@bamboo

JavaObjectSerializationCodec allows objects that support the Java Object Serialization protocol to be stored in the configuration cache.

The implementation is currently limited to serializable classes that implement the java.io.Serializable interface
and define one of the following combination of methods:

  • a writeObject method combined with a readObject method to control exactly which information to store;
  • a writeObject method with no corresponding readObject; writeObject must eventually call ObjectOutputStream.defaultWriteObject;
  • a readObject method with no corresponding writeObject; readObject must eventually call ObjectInputStream.defaultReadObject;
  • a writeReplace method to allow the class to nominate a replacement to be written (but see below);
  • a readResolve method to allow the class to nominate a replacement for the object just read;
  • serializable classes implementing the java.io.Externalizable interface (since Gradle 8.8)

The following Java Object Serialization features are not supported:

  • serializable classes implementing the java.io.Externalizable interface; objects of such classes are discarded by the configuration cache during serialization and reported as problems; (supported since Gradle 8.8)
  • the serialPersistentFields member to explicitly declare which fields are serializable; the member, if present, is ignored; the configuration cache considers all but transient fields serializable;
  • the following methods of ObjectOutputStream are not supported and will throw UnsupportedOperationException:
    • reset(), writeFields(), putFields(), writeChars(String), writeBytes(String) and writeUnshared(Any?).
  • the following methods of ObjectInputStream are not supported and will throw UnsupportedOperationException:
    • readLine(), readFully(ByteArray), readFully(ByteArray, Int, Int), readUnshared(), readFields(), transferTo(OutputStream) and readAllBytes().
  • validations registered via ObjectInputStream.registerValidation are simply ignored;
  • the readObjectNoData method, if present, is never invoked;
  • the serialization protocol isn't used when serializing the replacement returned by writeReplace.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions