Wednesday, October 16, 2002 10:53 AM
The result of a "clone" method can be fully "deep", or just 1-layer "shallow", or somewhere in between, so it depends on exactly how it is implemented, in the classes you are using -- not just the "clone" method in the top level object, but also the "clone" methods in all the member fields, and their own member fields, etc. all the way down.
Because of this, and issues with subclasses overriding "clone" vs. declaring a final version, and possibly not implementing it fully or even throwing "CloneNotSupported", most authors (e.g. Josh Bloch's "Effective Java", Bruce Eckel's "Thinking in Java", the "Java Practices" Web site) warn that you shouldn't depend on "clone" doing what you need, necessarily, if you don't have control over the code for all the objects involved.