--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/StackTrace.java 2017-08-03 23:36:41.618658405 +0900 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/StackTrace.java 2017-08-03 23:36:41.493658114 +0900 @@ -31,6 +31,11 @@ /** Traverses and prints the stack traces for all Java threads in the * remote VM */ public class StackTrace extends Tool { + + private static final String ADDRESS_FORMAT = VM.getVM().isLP64() ? "0x%016x" : "0x%08x"; + + private static final String LOCK_OUTPUT = " - locked <" + ADDRESS_FORMAT + "> (a %s)"; + // in non-verbose mode pc, sp and Method* are not printed public StackTrace(boolean v, boolean concurrentLocks) { this.verbose = v; @@ -109,6 +114,12 @@ } tty.println(")"); + + vf.getMonitors() + .stream() + .map(m -> m.ownerIsScalarReplaced() ? m.ownerKlass() : m.owner()) + .map(m -> String.format(LOCK_OUTPUT, m.asLongValue(), Oop.getKlassForOopHandle(m).getName().asString().replace('/', '.'))) + .forEach(tty::println); } } catch (Exception e) { tty.println("Error occurred during stack walking:");