@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) 这个注释不变。

1 thought on “scala2.9中@serializable注释已不鼓励使用

Leave a Reply

Your email address will not be published. Required fields are marked *