Hi Chris,
Looks good to me. It might also be beneficial to double check
that the hash codes of the two objects are equal.
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.