140 static unsigned int hash(oop java_string) {
141 assert(initialized && (hash_offset > 0), "Must be initialized");
142 assert(is_instance(java_string), "must be java_string");
143 return java_string->int_field(hash_offset);
144 }
145 static int offset(oop java_string) {
146 assert(initialized, "Must be initialized");
147 assert(is_instance(java_string), "must be java_string");
148 if (offset_offset > 0) {
149 return java_string->int_field(offset_offset);
150 } else {
151 return 0;
152 }
153 }
154 static int length(oop java_string) {
155 assert(initialized, "Must be initialized");
156 assert(is_instance(java_string), "must be java_string");
157 if (count_offset > 0) {
158 return java_string->int_field(count_offset);
159 } else {
160 return ((typeArrayOop)java_string->obj_field(value_offset))->length();
161 }
162 }
163 static int utf8_length(oop java_string);
164
165 // String converters
166 static char* as_utf8_string(oop java_string);
167 static char* as_utf8_string(oop java_string, char* buf, int buflen);
168 static char* as_utf8_string(oop java_string, int start, int len);
169 static char* as_utf8_string(oop java_string, int start, int len, char* buf, int buflen);
170 static char* as_platform_dependent_str(Handle java_string, TRAPS);
171 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
172 // produce an ascii string with all other values quoted using \u####
173 static char* as_quoted_ascii(oop java_string);
174
175 // Compute the hash value for a java.lang.String object which would
176 // contain the characters passed in.
177 //
178 // As the hash value used by the String object itself, in
179 // String.hashCode(). This value is normally calculated in Java code
180 // in the String.hashCode method(), but is precomputed for String
|
140 static unsigned int hash(oop java_string) {
141 assert(initialized && (hash_offset > 0), "Must be initialized");
142 assert(is_instance(java_string), "must be java_string");
143 return java_string->int_field(hash_offset);
144 }
145 static int offset(oop java_string) {
146 assert(initialized, "Must be initialized");
147 assert(is_instance(java_string), "must be java_string");
148 if (offset_offset > 0) {
149 return java_string->int_field(offset_offset);
150 } else {
151 return 0;
152 }
153 }
154 static int length(oop java_string) {
155 assert(initialized, "Must be initialized");
156 assert(is_instance(java_string), "must be java_string");
157 if (count_offset > 0) {
158 return java_string->int_field(count_offset);
159 } else {
160 typeArrayOop value_array = ((typeArrayOop)java_string->obj_field(value_offset));
161 if (value_array == NULL) {
162 return 0;
163 } else {
164 return value_array->length();
165 }
166 }
167 }
168 static int utf8_length(oop java_string);
169
170 // String converters
171 static char* as_utf8_string(oop java_string);
172 static char* as_utf8_string(oop java_string, char* buf, int buflen);
173 static char* as_utf8_string(oop java_string, int start, int len);
174 static char* as_utf8_string(oop java_string, int start, int len, char* buf, int buflen);
175 static char* as_platform_dependent_str(Handle java_string, TRAPS);
176 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
177 // produce an ascii string with all other values quoted using \u####
178 static char* as_quoted_ascii(oop java_string);
179
180 // Compute the hash value for a java.lang.String object which would
181 // contain the characters passed in.
182 //
183 // As the hash value used by the String object itself, in
184 // String.hashCode(). This value is normally calculated in Java code
185 // in the String.hashCode method(), but is precomputed for String
|