re PR libgcj/11241 (WeakHashMap throws a "/ zero" ArithmeticException when initialCap...
authorTom Tromey <tromey@redhat.com>
Fri, 1 Aug 2003 21:30:14 +0000 (21:30 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Fri, 1 Aug 2003 21:30:14 +0000 (21:30 +0000)
Fix for PR libgcj/11241:
* java/util/WeakHashMap.java (WeakHashMap(int,float)): If
initialCapacity is 0, set it to 1.

From-SVN: r70070

libjava/ChangeLog
libjava/java/util/WeakHashMap.java

index e42d79acaf8ecddc7b484c3a9c3816e478072a1c..71b863f2679926744c921c5efc7d68daab14ec92 100644 (file)
@@ -1,3 +1,9 @@
+2003-08-01  Tom Tromey  <tromey@redhat.com>
+
+       Fix for PR libgcj/11241:
+       * java/util/WeakHashMap.java (WeakHashMap(int,float)): If
+       initialCapacity is 0, set it to 1.
+
 2003-08-01  Stephen Crawley <crawley@dstc.edu.au>
 
        * java/net/SocketImpl.java (toString): Display the remote address
index 3431ac921e116f0789f8112f7de02aa97341026c..4cce821c5ff6d4418a47cfd60acbdcee10e0aba1 100644 (file)
@@ -1,6 +1,6 @@
 /* WeakHashMap -- a hashtable that keeps only weak references
    to its keys, allowing the virtual machine to reclaim them
-   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -544,6 +544,8 @@ public class WeakHashMap extends AbstractMap implements Map
     // Check loadFactor for NaN as well.
     if (initialCapacity < 0 || ! (loadFactor > 0))
       throw new IllegalArgumentException();
+    if (initialCapacity == 0)
+      initialCapacity = 1;
     this.loadFactor = loadFactor;
     threshold = (int) (initialCapacity * loadFactor);
     theEntrySet = new WeakEntrySet();