Question

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.

Was it helpful?

Solution

A Serializable class doesn't need a no-args constructor. Its nearest non-serializable base class does.

You've misread the specification.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top