Addendum (Re: Patch: FYI: clone System properties)

Tom Tromey tromey@redhat.com
Mon Feb 17 15:02:00 GMT 2003


>>>>> "Ranjit" == Ranjit Mathew <rmathew@hotmail.com> writes:

Tom> I thought about this more, and I think we don't need a clone
Tom> method, due to the way that Hashtable.clone is implemented.  I'm
Tom> going to leave that part out of your patch.

Ranjit> Can you please explain the reasoning? AFAICT, without this
Ranjit> clone() implementation, Properties.clone( ) would give you an
Ranjit> object that doesn't have the same behaviour with respect to
Ranjit> default values for keys.

Properties.clone() is inherited from Hashtable.  Hashtable.clone()
starts by calling `super.clone()', which is inherited from Object
(Dictionary doesn't implement clone).  Object.clone() does a low-level
(byte-for-byte) copy of the original object.  So, the `defaults' field
is copied after all; doing it again would be redundant.

My original post to the java list was incorrect about this.  I even
wrote a patch for it (the clone bit was exactly the same as your
implementation) before I realized that it wasn't necessary.

Tom



More information about the Java-patches mailing list