@serializable class X 

现已不鼓励,而用extends Serializable来替代

class X extends Serializable


The reason is that the compiler converts the annotation only during
type-checking, so depending on the order in which things type check,
there might be an error message (“required: Serializable”) or not.

The correct behavior would be to do the transformation earlier, but this is kind of a hack as some of you know (@BeanProperty), and we reallywant to avoid more annotations that influence typing.

完整见这里,以后应该直接用 extends Serializable
另, @SerialVersionUID(42) 这个注释不变。


电子邮件地址不会被公开。 必填项已用*标注