我正在查看Java 11 API更改的列表,这使我很困惑:
JDK更改集
8201793 :(参考)引用对象不应该支持克隆
http://hg.openjdk.java.net/jdk/jdk11/rev/e3653598e3b0
Reference.clone()源代码
/**
* Throws {@link CloneNotSupportedException}. A {@code Reference} cannot be
* meaningfully cloned. Construct a new {@code Reference} instead.
*
* @returns never returns normally
* @throws CloneNotSupportedException always
*
* @since 11
*/
@Override
protected Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
我假设一定有理由将其包含在内,也许将来会有所用?