--- old/src/hotspot/share/oops/symbol.hpp 2018-10-01 15:58:50.603826437 -0400 +++ new/src/hotspot/share/oops/symbol.hpp 2018-10-01 15:58:50.128124576 -0400 @@ -112,7 +112,7 @@ // in high half word. length is the number of UTF8 characters in the symbol volatile uint32_t _length_and_refcount; short _identity_hash; - jbyte _body[2]; + u1 _body[2]; enum { // max_symbol_length must fit into the top 16 bits of _length_and_refcount @@ -128,7 +128,7 @@ return (int)heap_word_size(byte_size(length)); } - void byte_at_put(int index, int value) { + void byte_at_put(int index, u1 value) { assert(index >=0 && index < length(), "symbol index overflow"); _body[index] = value; } @@ -148,7 +148,7 @@ public: // Low-level access (used with care, since not GC-safe) - const jbyte* base() const { return &_body[0]; } + const u1* base() const { return &_body[0]; } int size() { return size(utf8_length()); } int byte_size() { return byte_size(utf8_length()); } @@ -176,12 +176,26 @@ return (refcount() == PERM_REFCOUNT); } - int byte_at(int index) const { + // The byte_at() and char_at() functions return the same values but as + // different types. Function byte_at() should be called when the unsigned + // value of the byte is wanted. Function char_at() should be called when the + // result is going to be used as a char, such as when comparing the result + // to ']'. + // + // Note that all multi-byte chars have the sign bit set on all their bytes. + // No single byte chars have their sign bit set. + + u1 byte_at(int index) const { + assert(index >=0 && index < length(), "symbol index overflow"); + return base()[index]; + } + + char char_at(int index) const { assert(index >=0 && index < length(), "symbol index overflow"); return base()[index]; } - const jbyte* bytes() const { return base(); } + const u1* bytes() const { return base(); } int utf8_length() const { return length(); } @@ -190,7 +204,7 @@ int l = utf8_length(); if (l != len) return false; while (l-- > 0) { - if (str[l] != (char) byte_at(l)) + if (str[l] != char_at(l)) return false; } assert(l == -1, "we should be at the beginning");