re PR libgcj/11241 (WeakHashMap throws a "/ zero" ArithmeticException when initialCapacity is explicitly zero)
Fix for PR libgcj/11241: * java/util/WeakHashMap.java (WeakHashMap(int,float)): If initialCapacity is 0, set it to 1. From-SVN: r70070
This commit is contained in:
parent
6e42faef6d
commit
a04045d0a2
2 changed files with 9 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue