1.1 --- a/src/share/vm/classfile/javaClasses.hpp Thu Mar 31 02:31:57 2011 -0700 1.2 +++ b/src/share/vm/classfile/javaClasses.hpp Thu Mar 31 14:00:41 2011 -0700 1.3 @@ -109,6 +109,30 @@ 1.4 static char* as_platform_dependent_str(Handle java_string, TRAPS); 1.5 static jchar* as_unicode_string(oop java_string, int& length); 1.6 1.7 + // Compute the hash value for a java.lang.String object which would 1.8 + // contain the characters passed in. This hash value is used for at 1.9 + // least two purposes. 1.10 + // 1.11 + // (a) As the hash value used by the StringTable for bucket selection 1.12 + // and comparison (stored in the HashtableEntry structures). This 1.13 + // is used in the String.intern() method. 1.14 + // 1.15 + // (b) As the hash value used by the String object itself, in 1.16 + // String.hashCode(). This value is normally calculate in Java code 1.17 + // in the String.hashCode method(), but is precomputed for String 1.18 + // objects in the shared archive file. 1.19 + // 1.20 + // For this reason, THIS ALGORITHM MUST MATCH String.hashCode(). 1.21 + static unsigned int hash_string(jchar* s, int len) { 1.22 + unsigned int h = 0; 1.23 + while (len-- > 0) { 1.24 + h = 31*h + (unsigned int) *s; 1.25 + s++; 1.26 + } 1.27 + return h; 1.28 + } 1.29 + static unsigned int hash_string(oop java_string); 1.30 + 1.31 static bool equals(oop java_string, jchar* chars, int len); 1.32 1.33 // Conversion between '.' and '/' formats