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();
}
}
}
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();
}
}
}