コード例 #1
0
ファイル: SanityCheck.java プロジェクト: FauxFaux/jdk9-jdk
  public static void main(String[] args) throws Exception {
    for (int i = 0; i < 20; i++) {
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      ObjectOutputStream oout = new ObjectOutputStream(bout);
      Item item = new Item();
      oout.writeObject(item);
      oout.close();

      ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bout.toByteArray()));
      Item itemcopy = (Item) oin.readObject();

      if (!item.equals(itemcopy)) {
        throw new Error();
      }
    }
  }