United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4305102 : incomplete doc for Hashtable(int, float) and Hashtable(int)

Details
Type:
Bug
Submit Date:
2000-01-17
Status:
Closed
Updated Date:
2005-05-23
Project Name:
JDK
Resolved Date:
2005-05-23
Component:
docs
OS:
solaris_2.5,generic
Sub-Component:
guides
CPU:
sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.3.0,5.0
Fixed Versions:
5.0 (b28)

Related Reports

Sub Tasks

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


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



Hardware and Software, Engineered to Work Together