8201793: (ref) Reference object should not support cloning

Reviewed-by: psandoz, kbarrett
This commit is contained in:
Mandy Chung 2018-05-03 11:18:57 -07:00
parent 8ebfc59cfa
commit bd18ef4c18
2 changed files with 118 additions and 0 deletions

View file

@ -300,6 +300,20 @@ public abstract class Reference<T> {
return this.queue.enqueue(this);
}
/**
* 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();
}
/* -- Constructors -- */
Reference(T referent) {