RFR [1]6 8248326 Add a minimal serialization test for local records

Chris Hegarty chris.hegarty at oracle.com
Fri Jun 26 08:57:48 UTC 2020


> On 25 Jun 2020, at 16:24, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:
> 
> Hi Chris,
> 
> Looks good to me.

Thanks for the review Daniel.

> It might also be beneficial to double check
> that the hash codes of the two objects are equal.

Since no other tests in this area check the hash code, and this issue is narrowly focused on testing local records, then I’ll respectively decline the suggestion. If checking of the hash code is beneficial, we can consider it separately and in a larger context.

-Chris.

> best regards,
> 
> -- daniel
> 
> On 25/06/2020 16:01, Chris Hegarty wrote:
>> While working on some record serialization changes recently, I noticed that we don’t have any coverage for local records. Here is a simple extension to an existing records test.
>> diff -r 4e186efa6cbf test/jdk/java/io/Serializable/records/BasicRecordSer.java
>> --- a/test/jdk/java/io/Serializable/records/BasicRecordSer.java	Thu Jun 25 09:54:19 2020 +0100
>> +++ b/test/jdk/java/io/Serializable/records/BasicRecordSer.java	Thu Jun 25 15:40:13 2020 +0100
>> @@ -132,6 +132,20 @@
>>          assertEquals(objDeserialized, objToSerialize);
>>      }
>>  +    /** Tests serializing and deserializing of local records. */
>> +    @Test
>> +    public void testLocalRecord() throws Exception {
>> +        out.println("\n---");
>> +        record Point(int x, int y) implements Serializable { }
>> +        record Rectangle(Point bottomLeft, Point topRight) implements Serializable { }
>> +        var objToSerialize = new Rectangle(new Point(0, 1), new Point (5, 6));
>> +        out.println("serializing : " + objToSerialize);
>> +        var objDeserialized = serializeDeserialize(objToSerialize);
>> +        out.println("deserialized: " + objDeserialized);
>> +        assertEquals(objToSerialize, objDeserialized);
>> +        assertEquals(objDeserialized, objToSerialize);
>> +    }
>> +
>>      /** Tests back references of Serializable record objects in the stream. */
>>      @Test
>>      public void testSerializableBackRefs() throws Exception {
>> -Chris.
> 



More information about the core-libs-dev mailing list