Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4305102

incomplete doc for Hashtable(int, float) and Hashtable(int)

XMLWordPrintable

    • b28
    • generic, sparc
    • generic, solaris_2.5
    • Verified

      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;


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

            shommel Scott Hommel (Inactive)
            bkvartsk Boris Kvartskhava
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: