diff -r 3cd78165832b src/share/vm/oops/symbol.cpp --- a/src/share/vm/oops/symbol.cpp Tue Jun 02 10:41:18 2015 +0200 +++ b/src/share/vm/oops/symbol.cpp Wed Jun 10 10:47:06 2015 -0700 @@ -35,7 +35,7 @@ Symbol::Symbol(const u1* name, int length, int refcount) { _refcount = refcount; _length = length; - _identity_hash = os::random(); + _identity_hash = (short)os::random(); for (int i = 0; i < _length; i++) { byte_at_put(i, name[i]); } diff -r 3cd78165832b src/share/vm/oops/symbol.hpp --- a/src/share/vm/oops/symbol.hpp Tue Jun 02 10:41:18 2015 +0200 +++ b/src/share/vm/oops/symbol.hpp Wed Jun 10 10:47:06 2015 -0700 @@ -102,23 +102,17 @@ // type without virtual functions. class ClassLoaderData; -// We separate the fields in SymbolBase from Symbol::_body so that -// Symbol::size(int) can correctly calculate the space needed. -class SymbolBase : public MetaspaceObj { - public: +class Symbol : public MetaspaceObj { + private: ATOMIC_SHORT_PAIR( volatile short _refcount, // needs atomic operation unsigned short _length // number of UTF8 characters in the symbol (does not need atomic op) ); - int _identity_hash; -}; - -class Symbol : private SymbolBase { + short _identity_hash; + jbyte _body[2]; friend class VMStructs; friend class SymbolTable; friend class MoveSymbols; - private: - jbyte _body[1]; enum { // max_symbol_length is constrained by type of _length @@ -126,7 +120,7 @@ }; static int size(int length) { - size_t sz = heap_word_size(sizeof(SymbolBase) + (length > 0 ? length : 0)); + size_t sz = heap_word_size(sizeof(Symbol) + (length > 2 ? length - 2 : 0)); return align_object_size(sz); } diff -r 3cd78165832b src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Tue Jun 02 10:41:18 2015 +0200 +++ b/src/share/vm/runtime/vmStructs.cpp Wed Jun 10 10:47:06 2015 -0700 @@ -403,7 +403,7 @@ nonstatic_field(ObjArrayKlass, _element_klass, Klass*) \ nonstatic_field(ObjArrayKlass, _bottom_klass, Klass*) \ volatile_nonstatic_field(Symbol, _refcount, short) \ - nonstatic_field(Symbol, _identity_hash, int) \ + nonstatic_field(Symbol, _identity_hash, short) \ nonstatic_field(Symbol, _length, unsigned short) \ unchecked_nonstatic_field(Symbol, _body, sizeof(jbyte)) /* NOTE: no type */ \ nonstatic_field(TypeArrayKlass, _max_length, int) \