From 07add946aac1a64e5e94c2282eb3b3c033ce3867 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Fri, 16 Feb 2001 01:49:40 +0000 Subject: TreeSet.java (clone): Made subclass safe, use super.clone(), not new. * java/util/TreeSet.java (clone): Made subclass safe, use super.clone(), not new. * java/util/TreeMap.java (clone): Likewise. From-SVN: r39734 --- libjava/java/util/TreeSet.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libjava/java/util/TreeSet.java') diff --git a/libjava/java/util/TreeSet.java b/libjava/java/util/TreeSet.java index 070ca26..c6875b8 100644 --- a/libjava/java/util/TreeSet.java +++ b/libjava/java/util/TreeSet.java @@ -44,8 +44,8 @@ import java.io.ObjectOutputStream; * TreeSet is a part of the JDK1.2 Collections API. * * @author Jon Zeppieri - * @version $Revision: 1.1 $ - * @modified $Id: TreeSet.java,v 1.1 2001/02/14 04:44:21 bryce Exp $ + * @version $Revision: 1.2 $ + * @modified $Id: TreeSet.java,v 1.2 2001/02/15 03:59:57 bryce Exp $ */ public class TreeSet extends AbstractSet @@ -157,7 +157,14 @@ public class TreeSet extends AbstractSet /** Returns a shallow copy of this Set. */ public Object clone() { - TreeSet copy = new TreeSet(); + TreeSet copy = null; + try + { + copy = (TreeSet) super.clone(); + } + catch (CloneNotSupportedException x) + { + } copy.map = (SortedMap) ((TreeMap) map).clone(); return copy; } -- cgit v1.1