JDK11源码学习04 | Cloneable接口
package java.lang;
/**
* A class implements the <code>Cloneable</code> interface to
* indicate to the {@link java.lang.Object#clone()} method that it
* is legal for that method to make a
* field-for-field copy of instances of that class.
*
* 类实现Cloneable接口以向该Object.clone()方法指示该方法合法地为该类的实例制作字段的字段副本。
*
*
* Invoking Object's clone method on an instance that does not implement the
* <code>Cloneable</code> interface results in the exception
* <code>CloneNotSupportedException</code> being thrown.
*
* 在未实现Cloneable接口的实例上调用Object的clone方法会 导致 CloneNotSupportedException抛出异常。
*
*
* By convention, classes that implement this interface should override
* {@code Object.clone} (which is protected) with a public method.
* See {@link java.lang.Object#clone()} for details on overriding this
* method.
*
* 按照惯例,实现此接口的类应使用公共方法覆盖 Object.clone(它是 protected 的)。
*
*
* Note that this interface does <i>not</i> contain the {@code clone} method.
* Therefore, it is not possible to clone an object merely by virtue of the
* fact that it implements this interface. Even if the clone method is invoked
* reflectively, there is no guarantee that it will succeed.
*
* 请注意,这个接口并没有包含克隆方法。因此,仅仅通过实现该接口的事实来克隆对象是不可能的。
* 即使反射调用clone方法,也无法保证它会成功。
*
*
* @author unascribed
* @see java.lang.CloneNotSupportedException
* @see java.lang.Object#clone()
* @since 1.0
*/
public interface Cloneable {
}