JDK-4106818 : Provide a general way to make deep copies of objects
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 1998-01-26
  • Updated: 2017-02-07
Related Reports
Relates :  
Relates :  
Description

Name: rm29839			Date: 01/26/98


MT applications often need to make deep copies of
objects to be passed between threads. While Java
provides a way to make shallow copies using the
default implementation of Object.clone(), making
deep copies generally is very cumbersome and
sometimes even impossible. Currently the most
general way to achieve this is to serialize the
object and deserialize it again. This is
cumbersome, slow, and, worst of all, requires all
objects to be Serializable. The latter is
especially bad if you don't have the source code
to all classes you're using.

Replication of arbitrary data structures could be
implemented in a way simular to object
serialization, i.e. one could traverse the graph
the same way the ObjectOutputStream does, except
that each reached object would have to be cloned
instead of being written to some stream.
(Review ID: 23953)
======================================================================

Comments
EVALUATION Of course, one can always do this using reflection, but that is costly. On the other hand, what the appropriate notion of deep copy for a given class depends on its semantics. So it isn't clear that this is all that justified. gilad.bracha@eng 1998-01-26
26-01-1998