< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/PerfDataEntry.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -22,10 +22,11 @@
  *
  */
 
 package sun.jvm.hotspot.runtime;
 
+import java.nio.charset.*;
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;

@@ -360,15 +361,12 @@
             } else if (dataType == BasicType.getTChar()) {
                 // char[] is returned as a String
                 str = new String(charArrayValue());
             } else if (dataType == BasicType.getTByte()) {
                 // byte[] is returned as a String
-                try {
-                    str = new String(byteArrayValue(), "US-ASCII");
-                } catch (java.io.UnsupportedEncodingException e) {
-                    str = "can't decode string : " + e.getMessage();
-                }
+                str = CStringUtilities.getString(addr.addOffsetTo(dataOffset()),
+                                                 StandardCharsets.US_ASCII);
             } else if (dataType == BasicType.getTShort()) {
                 short[] res = shortArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
                 for (int i = 0; i < res.length; i++) {
< prev index next >