hotspot/src/share/vm/classfile/javaClasses.cpp
changeset 14477 95e66ea71f71
parent 14391 df0a1573d5bd
child 14490 5bb45ed999ee
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Fri Nov 09 08:36:17 2012 -0800
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Mon Nov 12 14:03:53 2012 -0800
@@ -348,6 +348,22 @@
   return java_lang_String::to_hash(value->char_at_addr(offset), length);
 }
 
+char* java_lang_String::as_quoted_ascii(oop java_string) {
+  typeArrayOop value  = java_lang_String::value(java_string);
+  int          offset = java_lang_String::offset(java_string);
+  int          length = java_lang_String::length(java_string);
+
+  jchar* base = (length == 0) ? NULL : value->char_at_addr(offset);
+  if (base == NULL) return NULL;
+
+  int result_length = UNICODE::quoted_ascii_length(base, length) + 1;
+  char* result = NEW_RESOURCE_ARRAY(char, result_length);
+  UNICODE::as_quoted_ascii(base, length, result, result_length);
+  assert(result_length >= length + 1, "must not be shorter");
+  assert(result_length == (int)strlen(result) + 1, "must match");
+  return result;
+}
+
 unsigned int java_lang_String::hash_string(oop java_string) {
   int          length = java_lang_String::length(java_string);
   // Zero length string doesn't hash necessarily hash to zero.