JDK-4305102 : incomplete doc for Hashtable(int, float) and Hashtable(int)
  • Type: Bug
  • Component: docs
  • Sub-Component: guides
  • Affected Version: 1.3.0,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_2.5
  • CPU: generic,sparc
  • Submitted: 2000-01-17
  • Updated: 2017-05-16
  • Resolved: 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 Availability Release.

To download the current JDK release, click here.
Other
5.0 b28Fixed
Description
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");
        else 
            System.out.println("PASSED");
    }
}
------------- output ---------------------
3,~/tmp;
java -fullversion
java full version "1.3.0-R"
3,~/tmp;
java Test1
FAILED: rehash() call expected
3,~/tmp;


======================================================================

Comments
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
17-09-2004

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
08-09-2003