[lworld] RFR: 8340409: [lworld] Simple serialization and deserialization of core migrated classes [v2]
Viktor Klang
vklang at openjdk.org
Tue Oct 8 21:23:16 UTC 2024
On Tue, 8 Oct 2024 19:34:00 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Serialization and deerialization of value classes.
>> For java.base value classes migrated from identity classes:
>> - Must be annotated with jdk.internal.MigratedValueClass (in tests too)
>> - Must have a constructor or static factory method:
>> - annotated with jdk.internal.value.DeserializeConstrucctor
>> - constructor parameters must match order and types of serializable fields of the class
>> - Value class must not have superclass with fields; only Object or abstract w/o fields
>> - Uses same technique as for Records to extract and concat values from stream to invoke constructor
>> - Migrated value classes are serialized using the same format/fields as the identity class
>>
>> Non-migrated value classes throw InvalidClassException
>>
>> Along the way, refactored code to break out different modes of deserialization: full custom deserialization with custom data, default deserialization only, externalizable, no local class, record, and then added mode to deserialize a value class.
>>
>> Updates to value class tests and added a combo test to check many combinations of value and identity classes with different parameters.
>
> Roger Riggs has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
>
> - Merge branch 'lworld' into 8340409-simple-value-deserialize
> - Merge branch 'lworld' into 8340409-simple-value-deserialize
> - 8340409: [lworld] Simple serialization and deserialization of core migrated classes
>
> Serialization and deerialization of value classes.
> For java.base value classes being migrated from identity classes:
> - Must be annotated with jdk.internal.MigratedValueClass (in tests too)
> - Must have a constructor or static factory method:
> - annotated with jdk.internal.value.DeserializeConstrucctor
> - constructor parameters must match order and types of serializable fields of the class
> - Value class must not have superclass with fields; only Object or abstract w/o fields
> - Uses same technique as for Records to extract and concat values from stream to invoke constructor
> - Migrated value classes are serialized using the same format/fields as the identity class
>
> Non-migrated value classes throw InvalidClassException
>
> Along the way, refactored code to break out different modes of deserialization:
> full custom deserialization with custom data, default deserialization only,
> externalizable, no local class, record, and then added mode to deserialize a value class.
>
> Updates to value class tests and added a combo test to check many combinations
> of value and identity classes with different parameters.
src/java.base/share/classes/java/io/ObjectStreamClass.java line 1894:
> 1892:
> 1893: int argIndex = 0;
> 1894: for (int i = 0; i < clFields.length; i++) {
Suggestion:
for (int i = 0, argIndex = 0; i < clFields.length; i++) {
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1248#discussion_r1792525148
More information about the valhalla-dev
mailing list