From 480fdd064cc2caa3e3adc78ec762aaa286ce4a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20L=C3=B3pez?= Date: Sat, 10 Oct 2020 09:40:04 +0200 Subject: [PATCH] Add missing readResolve() method in serialization proxy example --- src/effectivejava/chapter12/item90/Period.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/effectivejava/chapter12/item90/Period.java b/src/effectivejava/chapter12/item90/Period.java index 71aaf712..07df3731 100644 --- a/src/effectivejava/chapter12/item90/Period.java +++ b/src/effectivejava/chapter12/item90/Period.java @@ -43,6 +43,10 @@ private static class SerializationProxy implements Serializable { private static final long serialVersionUID = 234098243823485285L; // Any number will do (Item 87) + + private Object readResolve() { + return new Period(start, end); // Uses public constructor + } } // writeReplace method for the serialization proxy pattern