Mercurial > hg > truffle
diff agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java @ 3945:8ed53447f690
Merge
author | iveresov |
---|---|
date | Thu, 15 Sep 2011 12:44:09 -0700 |
parents | f6f3bb0ee072 |
children | cfa2c82f4c04 |
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java Tue Sep 13 20:28:00 2011 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java Thu Sep 15 12:44:09 2011 -0700 @@ -112,6 +112,32 @@ return buf.toString(); } + public static String escapeString(String s) { + StringBuilder sb = null; + for (int index = 0; index < s.length(); index++) { + char value = s.charAt(index); + if (value >= 32 && value < 127 || value == '\'' || value == '\\') { + if (sb != null) { + sb.append(value); + } + } else { + if (sb == null) { + sb = new StringBuilder(s.length() * 2); + sb.append(s, 0, index); + } + sb.append("\\u"); + if (value < 0x10) sb.append("000"); + else if (value < 0x100) sb.append("00"); + else if (value < 0x1000) sb.append("0"); + sb.append(Integer.toHexString(value)); + } + } + if (sb != null) { + return sb.toString(); + } + return s; + } + public static String stringOopToString(Oop stringOop) { if (offsetField == null) { InstanceKlass k = (InstanceKlass) stringOop.getKlass(); @@ -129,6 +155,10 @@ countField.getValue(stringOop)); } + public static String stringOopToEscapedString(Oop stringOop) { + return escapeString(stringOopToString(stringOop)); + } + private static void initThreadGroupFields() { if (threadGroupParentField == null) { SystemDictionary sysDict = VM.getVM().getSystemDictionary();