@Test public void serializable() throws IOException, ClassNotFoundException { Unit unit = Unit.unit(); byte[] bytes; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos);) { out.writeObject(unit); out.flush(); bytes = baos.toByteArray(); } Object result; try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes))) { result = in.readObject(); } assertSame(unit, result); }
private Unit() {}
Unit implements Serializable { private Unit() {} }
Unit implements Serializable { private Unit() {} private  Unit(); }
Unit implements Serializable { private Unit() {} private  Unit(); static Unit unit(); @Override String toString(); }
Unit implements Serializable { private Unit() {} private  Unit(); static Unit unit(); @Override String toString();  }