HashSet.java (clone): Made subclass safe, use super.clone(), not new.
authorBryce McKinlay <bryce@albatross.co.nz>
Fri, 16 Feb 2001 04:50:38 +0000 (04:50 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Fri, 16 Feb 2001 04:50:38 +0000 (04:50 +0000)
* java/util/HashSet.java (clone): Made subclass safe, use
super.clone(), not new.

From-SVN: r39746

libjava/ChangeLog
libjava/java/util/HashSet.java

index f3b77a1..51caaa9 100644 (file)
@@ -6,6 +6,9 @@
        
        * java/util/TreeMap.java (nil): Made non-final.
        (clone): Create new nil node for copy.
+       
+       * java/util/HashSet.java (clone): Made subclass safe, use 
+       super.clone(), not new.
 
 2001-02-14  Andrew Haley  <aph@redhat.com>
 
index c1a5218..228e419 100644 (file)
@@ -45,8 +45,8 @@ import java.io.ObjectOutputStream;
  * HashSet is a part of the JDK1.2 Collections API.
  *
  * @author      Jon Zeppieri
- * @version     $Revision: 1.2 $
- * @modified    $Id: HashSet.java,v 1.2 2001/02/14 04:44:21 bryce Exp $
+ * @version     $Revision: 1.3 $
+ * @modified    $Id: HashSet.java,v 1.3 2001/02/15 05:12:05 bryce Exp $
  */
 public class HashSet extends AbstractSet
   implements Set, Cloneable, Serializable
@@ -128,7 +128,14 @@ public class HashSet extends AbstractSet
    */
   public Object clone()
   {
-    HashSet copy = new HashSet();
+    HashSet copy = null;
+    try
+      {
+       copy = (HashSet) super.clone();
+      }
+    catch (CloneNotSupportedException x)
+      {
+      }
     copy.map = (HashMap) map.clone();
     return copy;
   }