五分钟源码Java【Serializable接口IV】
*
* Serializable classes that need to designate an alternative object to be
* used when writing an object to the stream should implement this
* special method with the exact signature:
* 译:
* 在将对象写入流时,需要指定替代对象的可序列化的类需要实现以下的方法:
*
* ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException;
*
* This writeReplace method is invoked by serialization if the method
* exists and it would be accessible from a method defined within the
* class of the object being serialized. Thus, the method can have private,
* protected and package-private access. Subclass access to this method
* follows java accessibility rules.
* 译:
* 这个writeReplace方法是通过序列化来调用的,
* 如果这个方法存在的话,它可以从被序列化的对象的类中定义的方法访问。
* 因此,该方法可以具有private的,protected 的和package-private的访问。
* 这个方法的子类访问遵循java可访问性规则。
*
* Classes that need to designate a replacement when an instance of it
* is read from the stream should implement this special method with the
* exact signature.
* 译:
* 当从流中读取实例的时候,
* 需要指定替换的类应该使用以下确切的签名来实现这个特殊的方法。
*
* ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;
*
* This readResolve method follows the same invocation rules and
* accessibility rules as writeReplace.
* 译:
* 这个readResolve方法遵循与writeReplace相同的调用规则和可访问性规则。
*