diff src/share/vm/oops/symbolOop.cpp @ 222:2a1a77d3458f

6718676: putback for 6604014 is incomplete Reviewed-by: kvn, jrose
author never
date Tue, 24 Jun 2008 16:00:14 -0700
parents a61af66fc99e
children dd57230ba8fe
line wrap: on
line diff
--- a/src/share/vm/oops/symbolOop.cpp	Tue Jun 24 10:43:29 2008 -0700
+++ b/src/share/vm/oops/symbolOop.cpp	Tue Jun 24 16:00:14 2008 -0700
@@ -68,8 +68,17 @@
 
 void symbolOopDesc::print_symbol_on(outputStream* st) {
   st = st ? st : tty;
-  for (int index = 0; index < utf8_length(); index++)
-    st->put((char)byte_at(index));
+  int length = UTF8::unicode_length((const char*)bytes(), utf8_length());
+  const char *ptr = (const char *)bytes();
+  jchar value;
+  for (int index = 0; index < length; index++) {
+    ptr = UTF8::next(ptr, &value);
+    if (value >= 32 && value < 127 || value == '\'' || value == '\\') {
+      st->put(value);
+    } else {
+      st->print("\\u%04x", value);
+    }
+  }
 }
 
 jchar* symbolOopDesc::as_unicode(int& length) const {