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]

PATCH: IdentityHashMap fixlet


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;


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