--- old/src/share/vm/oops/symbol.hpp 2015-04-15 12:03:16.097334698 -0700 +++ new/src/share/vm/oops/symbol.hpp 2015-04-15 12:03:15.954324700 -0700 @@ -223,6 +223,28 @@ void print() { print_on(tty); } void print_value() { print_value_on(tty); } + // Allows two distinct Symbol objects to be considered equal as long as + // they contain the same string. However, no two Symbol objects stored in the same + // SymbolTable would contain the same string. Therefore, if two distinct Symbol + // objects contain the same string, they must belong to different SymbolTables. + inline bool equals(const Symbol* other) const { + if (this && other) { + int len = this->utf8_length(); + if (len != other->utf8_length()) { + return false; + } + if (this->_identity_hash != other->_identity_hash) { + return false; + } + return (strncmp((const char*)(this->base()), (const char*)(other->base()), len) == 0); + } else { + return (this == other); + } + } + inline bool not_equals(const Symbol* other) const { + return !(this->equals(other)); + } + #ifndef PRODUCT // Empty constructor to create a dummy symbol object on stack // only for getting its vtable pointer.