--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java 2016-03-12 23:14:42.183423955 +0900 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java 2016-03-12 23:14:42.019424693 +0900 @@ -85,7 +85,7 @@ return commonHelp(); } - private static boolean toolHelp(String toolName) { + public static boolean toolHelp(String toolName) { if (toolName.equals("jstack")) { return jstackHelp(); } --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java 2016-03-12 23:14:42.754421385 +0900 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java 2016-03-12 23:14:42.605422056 +0900 @@ -134,8 +134,10 @@ new JInfo(mode).usage(); } - JInfo jinfo = new JInfo(mode); - jinfo.execute(args); + if (mode != -1) { + JInfo jinfo = new JInfo(mode); + jinfo.execute(args); + } } private void printVMFlags() { --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/Tool.java 2016-03-12 23:14:43.357418672 +0900 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/Tool.java 2016-03-12 23:14:43.168419522 +0900 @@ -27,6 +27,7 @@ import java.io.PrintStream; import sun.jvm.hotspot.HotSpotAgent; +import sun.jvm.hotspot.SALauncher; import sun.jvm.hotspot.debugger.DebuggerException; import sun.jvm.hotspot.debugger.JVMDebugger; import sun.jvm.hotspot.runtime.VM; @@ -98,7 +99,17 @@ } protected void usage() { - printUsage(); + StackWalker walker = StackWalker.getInstance( + StackWalker.Option.RETAIN_CLASS_REFERENCE); + Boolean throughSALauncher = walker.walk(s -> + s.map(StackWalker.StackFrame::getDeclaringClass) + .anyMatch(c -> c.equals(SALauncher.class))); + if (throughSALauncher.booleanValue()) { + String toolName = this.getClass().getSimpleName().toLowerCase(); + SALauncher.toolHelp(toolName); + } else { + printUsage(); + } } /*