--- old/src/java.base/share/classes/sun/security/ssl/Debug.java Fri May 29 00:47:48 2015 +++ new/src/java.base/share/classes/sun/security/ssl/Debug.java Fri May 29 00:47:48 2015 @@ -29,6 +29,9 @@ import java.security.AccessController; import java.util.Locale; +import sun.misc.HexDumpEncoder; +import java.nio.ByteBuffer; + import sun.security.action.GetPropertyAction; /** @@ -198,4 +201,47 @@ static String toString(byte[] b) { return sun.security.util.Debug.toString(b); } + + static void printHex(String prefix, byte[] bytes) { + HexDumpEncoder dump = new HexDumpEncoder(); + + synchronized (System.out) { + System.out.println(prefix); + try { + dump.encodeBuffer(bytes, System.out); + } catch (Exception e) { + // ignore + } + System.out.flush(); + } + } + + static void printHex(String prefix, ByteBuffer bb) { + HexDumpEncoder dump = new HexDumpEncoder(); + + synchronized (System.out) { + System.out.println(prefix); + try { + dump.encodeBuffer(bb.slice(), System.out); + } catch (Exception e) { + // ignore + } + System.out.flush(); + } + } + + static void printHex(String prefix, byte[] bytes, int offset, int length) { + HexDumpEncoder dump = new HexDumpEncoder(); + + synchronized (System.out) { + System.out.println(prefix); + try { + ByteBuffer bb = ByteBuffer.wrap(bytes, offset, length); + dump.encodeBuffer(bb, System.out); + } catch (Exception e) { + // ignore + } + System.out.flush(); + } + } }