Deserialization of a linked list of records
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed Mar 3 10:58:12 UTC 2021
> De: "Chris Hegarty" <chris.hegarty at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>, "amber-dev"
> <amber-dev at openjdk.java.net>
> Envoyé: Dimanche 28 Février 2021 17:42:41
> Objet: Re: Deserialization of a linked list of records
> [resending; in an effort to produce a less garbled version]
> Remi,
>>> On 26 Feb 2021, at 22:06, Remi Forax < [ mailto:forax at univ-mlv.fr |
>> > forax at univ-mlv.fr ] > wrote:
>>>[sent to both email list given it's not clear if it's an implementation issue or
>> >a spec issue]
>>>There is a nice video of how the serialization of records works recently on
>> >inside.java
>>> [ https://inside.java/2021/02/23/records-met-serialization/ |
>> > https://inside.java/2021/02/23/records-met-serialization/ ]
> Yes, this is a nice explanation of how record serialization works.
>>> In the video, Julia explains that the de-serialization works from bottom-up, so
>> > what if the record instances are a linked list …
>> > answer: a stack overflow.
> This reproducer fails on my machine with a StackOveflowException when
> serializing ( not de-serializing ).
> It fails with:
> Exception in thread "main" java.lang.StackOverflowError
> at
> java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1142)
> at
> java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1577)
> at
> java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1534)
> at
> java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1443)
> at
> java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1186)
> at
> java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1577)
> at
> java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1534)
> at
> java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1443)
> at
> java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1186)
> at
> java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1577)
> at
> java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1534)
> at
> java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1443)
> at
> java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1186)
> at
> java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1577)
> ...
> The same is true if Link is a normal class ( not a record class ).
oops, yes, you are right !
> Records and normal classes share the same code path in OOS when serializing.
exact, i now remember that i have reviewed the code that introduces the serialization of records,
sorry for the noise.
> -Chris.
Rémi
More information about the amber-dev
mailing list