JDK-4305102 : incomplete doc for Hashtable(int, float) and Hashtable(int)
  • Type: Bug
  • Status: Closed
  • Resolution: Fixed
  • Component: docs
  • Sub-Component: guides
  • Priority: P4
  • Affected Version: 1.3.0,5.0
  • OS: generic,solaris_2.5
  • CPU: generic,sparc
  • Submit Date: 2000-01-17
  • Updated Date: 2017-05-16
  • Resolved Date: 2005-05-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
5.0 b28Fixed
Name: bkC97677			Date: 01/17/2000

JavaDoc for java.util.Hashtable says:
"...When the number of entries in the hashtable 
exceeds the product of the load factor and 
the current capacity, the capacity is increased 
by calling the rehash method".

But there are cases when it is not true.
(For example, if initialCapacity equal to 0
is passed to the Hashtable constructor,
rehash() method should be called from 
first put(...) call".

Here is the test demonstrating this bug:
--------------- Test1.java -----------------------
import java.util.Hashtable;
class Child extends Hashtable {
    public Child(int ic, float lf) {
        super(ic, lf);

    protected void rehash () {
        rehashCalled = true;

    public boolean rehashCalled = false;

public class Test1 {
    public static void main(String[] args) {
        Child child = new Child(0, 1);
        child.put(new Object(), new Object());

        if (!child.rehashCalled)
            System.out.println("FAILED: rehash() call expected");
------------- output ---------------------
java -fullversion
java full version "1.3.0-R"
java Test1
FAILED: rehash() call expected


CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic tiger-beta FIXED IN: tiger tiger-beta INTEGRATED IN: tiger-b28 tiger-beta VERIFIED IN: 1.5

EVALUATION Will add the following to the class summary, per engineering's request: The "initial capacity" and "load factor" parameters are merely hints to the implementation. The exact details as to when and whether the rehash method is called are implementation dependent. ###@###.### 2003-09-08