< prev index next >

src/java.base/share/classes/java/util/Hashtable.java

Print this page
imported patch loadFactor-isNaN

*** 182,195 **** * @exception IllegalArgumentException if the initial capacity is less * than zero, or if the load factor is nonpositive. */ public Hashtable(int initialCapacity, float loadFactor) { if (initialCapacity < 0) ! throw new IllegalArgumentException("Illegal Capacity: "+ initialCapacity); ! if (loadFactor <= 0 || Float.isNaN(loadFactor)) ! throw new IllegalArgumentException("Illegal Load: "+loadFactor); if (initialCapacity==0) initialCapacity = 1; this.loadFactor = loadFactor; table = new Entry<?,?>[initialCapacity]; --- 182,196 ---- * @exception IllegalArgumentException if the initial capacity is less * than zero, or if the load factor is nonpositive. */ public Hashtable(int initialCapacity, float loadFactor) { if (initialCapacity < 0) ! throw new IllegalArgumentException("Illegal Capacity: " + initialCapacity); ! if (!(loadFactor > 0)) // also checks for NaNs ! throw new IllegalArgumentException("Illegal load factor: " + ! loadFactor); if (initialCapacity==0) initialCapacity = 1; this.loadFactor = loadFactor; table = new Entry<?,?>[initialCapacity];
*** 1267,1278 **** throws IOException, ClassNotFoundException { // Read in the threshold and loadFactor s.defaultReadObject(); // Validate loadFactor (ignore threshold - it will be re-computed) ! if (loadFactor <= 0 || Float.isNaN(loadFactor)) ! throw new StreamCorruptedException("Illegal Load: " + loadFactor); // Read the original length of the array and number of elements int origlength = s.readInt(); int elements = s.readInt(); --- 1268,1280 ---- throws IOException, ClassNotFoundException { // Read in the threshold and loadFactor s.defaultReadObject(); // Validate loadFactor (ignore threshold - it will be re-computed) ! if (!(loadFactor > 0)) // also checks for NaNs ! throw new StreamCorruptedException("Illegal load factor: " + ! loadFactor); // Read the original length of the array and number of elements int origlength = s.readInt(); int elements = s.readInt();
< prev index next >