Hashtable.hashCode causes stack overflow if hashtable was put into itself

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P2
    • 1.3.1_01
    • Affects Version/s: 1.3.1_01
    • Component/s: core-libs
    • None
    • 01a
    • x86
    • windows_nt
    • Verified

                During our applet compatibility testing, we found a small amount
        of applets run into a problem in Hashtable.hashCode() and result in
                java.lang.StackOverflowError
                 at java.util.Hashtable$Entry.hashCode(Unknown Source)

                The issue is that these applets put the hashtable object into itself
        for some unknown reasons, and try to generate a hashCode. This causes
        the following code in java.util.Hashtable to execute:

            public synchronized int hashCode() {
                int h = 0;
                Iterator i = entrySet().iterator();
                while (i.hasNext())
                    h += i.next().hashCode();
                return h;
            }

                It will end up being a recursive call and cause stack overflow.
        These applets work fine in MS VM because M$'s implementation of hashCode()
        doesn't rely on the hashCode of the entries.

        URL: www.playsite.com
        Release: J2SE v1.3.1_01a, 1.4.
        Platform: Win32

              Assignee:
              Josh Bloch (Inactive)
              Reporter:
              Stanley Ho (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: