2

I am trying to serialize a UUID with the Titan graph database and I believe I cannot because per the definition of Serializable, java.util.UUID fails to provide a no-arg constructor.

(See top of http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html for this)

Given that java.util.UUID claims to implement Serializable, what's going on here? Is this just a historical mistake that can't be removed for backward compatbility, or is there a specific technical reason for this weird (and to me, annoying) choice?

Update: Per the answer, UUID actually is Serializable and I misread the no-arg constructor rule which is subtle and does not actually require a no-arg constructor in the same class. The reason I couldn't serialize mine is that Titan (or its dependencies) adds a stricter no-arg declared constructor rule -- not core Java. I was confused as to who was imposing this rule, Java or Titan.

4

1 回答 1

2

Serializable 类不需要无参数构造函数。它最近的不可序列化基类确实如此。

你误读了规范。

于 2014-03-11T18:14:38.913 回答