Java: Rationale of the Cloneable interface

Ande Turner picture Ande Turner · Apr 2, 2009 · Viewed 7.6k times · Source

Why wasn't the .clone() method specified in the java.lang.Cloneable interface ?

Answer

Bill the Lizard picture Bill the Lizard · Apr 2, 2009

Basically, it's a broken interface. Ken Arnold and Bill Venners discussed it in Java Design Issues.

Arnold:

If I were to be God at this point, and many people are probably glad I am not, I would say deprecate Cloneable and have a Copyable, because Cloneable has problems. Besides the fact that it's misspelled, Cloneable doesn't contain the clone method. That means you can't test if something is an instance of Cloneable, cast it to Cloneable, and invoke clone. You have to use reflection again, which is awful. That is only one problem, but one I'd certainly solve.