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

Hashtable::print() does not work for types that don't have a print method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P3 P3
    • 10
    • 9
    • hotspot

      For example, if you instantiate Hashtable with T=address, like this:

          template class Hashtable<address, mtTracing>;

      The compilation of hashtable.cpp will fail:

      hashtable.cpp:322:7: error: request for member 'print' in '* entry->HashtableEntry<T, F>::literal<unsigned char*, (MemoryType)14u>()', which is of non-class type 'unsigned char'
             entry->literal()->print();
             ^

      This is because hashtable.cpp (http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/2346329fbbb3/src/share/vm/utilities/hashtable.cpp) assumes T->print() is a valid statement:

      template <class T, MEMFLAGS F> void Hashtable<T, F>::print() {
        ResourceMark rm;

        for (int i = 0; i < BasicHashtable<F>::table_size(); i++) {
          HashtableEntry<T, F>* entry = bucket(i);
          while(entry != NULL) {
            tty->print("%d : ", i);
            entry->literal()->print();
            tty->cr();
            entry = entry->next();
          }
        }
      }

            coleenp Coleen Phillimore
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: