code: private void readObject(ObjectInputStream stream) throws IOException {
          try {
              decode(stream);
          } catch (InvalidKeyException e) {
              e.printStackTrace();
              throw new IOException("deserialized key is invalid: " +
                                    e.getMessage());
          }
      }
docs: Serialization read ... X.509 keys serialize as
  themselves, and they're parsed when they get read back.