/* package whatever; // don't place package name! */

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

class Ideone {

    public static class Elvis implements Serializable {
        { System.out.println("Initializer of " + this); }
        private Elvis() { System.out.println("Constructor of " + this); }
        public static final Elvis THE_ELVIS = new Elvis();
        private Object readResolve() {
            System.out.println("readResolve of " + this);
            new Exception("This is how we get called:").printStackTrace();
            return THE_ELVIS;
        }
    }

    public static void main(String[] args) throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream oout = new ObjectOutputStream(out);
        oout.writeObject(Elvis.THE_ELVIS);
        oout.close();
        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
        Object object = in.readObject();
        System.out.println("Deserialized : " + object);
    }
}