--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java 2016-05-04 23:35:40.402514640 +0900 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java 2016-05-04 23:35:40.250515194 +0900 @@ -73,6 +73,7 @@ System.out.println(" \tto print same info as Solaris pmap"); System.out.println(" --heap\tto print java heap summary"); System.out.println(" --binaryheap\tto dump java heap in hprof binary format"); + System.out.println(" --dumpfile\tname of the dump file"); System.out.println(" --histo\tto print histogram of java object heap"); System.out.println(" --clstats\tto print class loader statistics"); System.out.println(" --finalizerinfo\tto print information on objects awaiting finalization"); @@ -241,13 +242,15 @@ private static void runJMAP(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs); String[] longOpts = {"exe=", "core=", "pid=", - "heap", "binaryheap", "histo", "clstats", "finalizerinfo"}; + "heap", "binaryheap", "dumpfile=", "histo", "clstats", "finalizerinfo"}; ArrayList newArgs = new ArrayList(); String pid = null; String exe = null; String core = null; String s = null; + String dumpfile = null; + boolean requestHeapdump = false; while((s = sg.next(null, longOpts)) != null) { if (s.equals("exe")) { @@ -267,7 +270,11 @@ continue; } if (s.equals("binaryheap")) { - newArgs.add("-heap:format=b"); + requestHeapdump = true; + continue; + } + if (s.equals("dumpfile")) { + dumpfile = sg.getOptarg(); continue; } if (s.equals("histo")) { @@ -284,6 +291,16 @@ } } + if (requestHeapdump) { + if (dumpfile == null) { + newArgs.add("-heap:format=b"); + } else { + newArgs.add("-heap:format=b,file=" + dumpfile); + } + } else if (dumpfile != null) { + throw new IllegalArgumentException("dumpfile does not need."); + } + buildAttachArgs(newArgs, pid, exe, core, false); JMap.main(newArgs.toArray(new String[newArgs.size()])); }