[lworld] RFR: 8281295: Prototype serialization/deserialization using Unsafe.

ExE Boss duke at openjdk.org
Wed Sep 21 04:41:16 UTC 2022


On Mon, 19 Sep 2022 18:21:31 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Specify serialization and deserialization of value objects. Value objects are immutable, Externalizable relies on mutation, Externalizable is not supported for value objects. Revised tests and added tests for graphs of value objects.
> 
> Somewhat similar to Record serialization in that back references to the value object store 'null' until the value object is completely deserialized.
> Similar to regular serialization/deserialization of identity objects.  The serialized form is the same.
> Deserialization is done by reading fields and storing into a Buffered larval object, converted to a value object when all of the fields have been read and stored.
> 
> Externalizable and Value Objects are incompatible, value objects are immutable and Externalizable.readExternal is expected to modify the fields of an allocated object.

src/java.base/share/classes/java/io/ObjectInputStream.java line 2307:

> 2305:                 handles.setObject(passHandle, obj);
> 2306:             readSerialData(obj, desc);
> 2307:         }

These `assert obj != null` statements can be hoisted before all these `if`‑statements.

-------------

PR: https://git.openjdk.org/valhalla/pull/761



More information about the valhalla-dev mailing list