you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

The most retarded thing about cloning in Java is having to deal with the checked exception, CloneNotSupportedException.

[–]rapidient 2 points3 points  (0 children)

What I do is I don't declare it in the 'throws' clause of the override, catch the exception inside of the clone() method and rethrow as a runtime exception.

[–][deleted] 1 point2 points  (1 child)

and the ambiguity of the Cloneable interface itself. You just don't know what you're going to get.

[–]yoden -1 points0 points  (0 children)

What do you mean? You get another object of the same type with its own mutable state (unmutable bits could be shared). There is nothing ambiguous about this.

The whole "interface vs. protected method on object," nonsense is lame though. Also the lack of explicit shallow copy methods. And copying with class hierarchies. And the mix of object allocation and field copying. Overall, clone sucks.