[lworld] RFR: 8281295: Prototype serialization/deserialization using Unsafe. [v3]
Mandy Chung
mchung at openjdk.org
Wed Oct 12 22:57:24 UTC 2022
On Thu, 29 Sep 2022 19:45:46 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.
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove asserts checking for null in cases where null signals there is no local class
> and the fields of the class in the stream are to be read and discarded.
This seems a reasonable way to provide a minimal serialization support for value classes to allow proper solution to be explored.
src/java.base/share/classes/java/io/ObjectStreamClass.java line 2100:
> 2098: vals[offsets[i]] = switch (typeCodes[i]) {
> 2099: case 'L', '[' ->
> 2100: unsafe.isFlattened(f)
Flattened field has `Q` descriptor. This PR doesn't support primitive class, right?
src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java line 335:
> 333: return constructorToCall;
> 334: }
> 335: if (cl.isValue()) {
Perhaps `newConstructorForExternalization` should also throw UOE if the given class is a value class?
-------------
PR: https://git.openjdk.org/valhalla/pull/761
More information about the valhalla-dev
mailing list