This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

TreeMap.clone (yet again)


I'm pretty sure we have it right this time ;-)

2001-02-16  Bryce McKinlay  <bryce@albatross.co.nz>

 * java/util/TreeMap.java (nil): Made non-final.
 (clone): Create new nil node for copy.

Index: java/util/TreeMap.java
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/util/TreeMap.java,v
retrieving revision 1.3
diff -u -r1.3 TreeMap.java
--- TreeMap.java        2001/02/16 01:49:40     1.3
+++ TreeMap.java        2001/02/16 02:23:27
@@ -67,7 +67,7 @@
   /** Sentinal node, used to avoid null checks for corner cases and
make the
       delete rebalance code simpler. Note that this must not be
static, due
       to thread-safety concerns. */
-  transient final Node nil = new Node(null, null);
+  transient Node nil = new Node(null, null);

   /** The root node of this TreeMap */
   transient Node root = nil;
@@ -186,6 +186,8 @@
     catch (CloneNotSupportedException x)
       {
       }
+    // Each instance must have a unique sentinal.
+    copy.nil = new Node(null, null);
     copy.fabricateTree(size);

     Node node = firstNode();



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]