PATCH: IdentityHashMap fixlet

Jeff Sturm jsturm@one-point.com
Sat Aug 18 15:20:00 GMT 2001


After updating my tree I began to see ArrayIndexOutOfBoundsExeptions
coming from JNI code.  This stops the exceptions.  (Other than this I
haven't really tested IdentityHashMap at all.)

2001-08-18  Jeff Sturm  <jsturm@one-point.com>

	* java/util/IdentityHashMap.java (get): Fix off-by-one error.
	(put): Likewise.

Index: java/util/IdentityHashMap.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/IdentityHashMap.java,v
retrieving revision 1.1
diff -u -p -r1.1 IdentityHashMap.java
--- IdentityHashMap.java	2001/08/15 20:46:48	1.1
+++ IdentityHashMap.java	2001/08/18 21:30:57
@@ -172,7 +172,7 @@ public class IdentityHashMap extends Abs
 	if (table[h] == emptyslot)
 	  return null;
 	h += 2;
-	if (h > table.length)
+	if (h >= table.length)
 	  h = 0;
 	if (h == save)
 	  return null;
@@ -257,7 +257,7 @@ public class IdentityHashMap extends Abs
 	    break;
 	  }
 	h += 2;
-	if (h > table.length)
+	if (h >= table.length)
 	  h = 0;
 	if (h == save)
 	  break;



More information about the Java-patches mailing list