RFR: 8271303: jcmd VM.cds {static, dynamic}_dump should print more info

Ioi Lam iklam at openjdk.java.net
Fri Sep 24 06:54:00 UTC 2021


On Thu, 23 Sep 2021 00:52:40 GMT, Yumin Qi <minqi at openjdk.org> wrote:

> Hi, please review the change for printing more info in jcmd terminal when dump shared archives. The ultimate shared archive file name is formed in java function (CDS.dumpSharedArchive) so to get the final archive name, the signature of CDS.dumpSharedArchive changed to return the archive name. At the end of dumping, return the archive name back to the caller so we can print out it in jcmd terminal.
> 
> Tests: ter1-4
>            manually checked the output of jcmd execution.
> 
> Thanks
> Yumin

Changes requested by iklam (Reviewer).

src/java.base/share/classes/jdk/internal/misc/CDS.java line 337:

> 335:         }
> 336:         // Everyting goes well, print out the file name.
> 337:         String archiveFilePath = cwd + File.separator + archiveFileName;

`archiveFileName` may already be a absolute path (e.g., "/tmp/foo.jar"), so this will print out something like /app/cwd//tmp/foo.jar, which will be incorrect. It should be changed to


String archiveFilePath = new File(archiveFileName).getAbsolutePath();

src/java.base/share/classes/jdk/internal/misc/CDS.java line 338:

> 336:         // Everyting goes well, print out the file name.
> 337:         String archiveFilePath = cwd + File.separator + archiveFileName;
> 338:         System.out.println("The process was attached by jcmd and do a " + (isStatic ? "static" : "dynamic") + " dump to file " + archiveFilePath);

Grammar:


System.out.println("The process was attached by jcmd and dumped a "
     + (isStatic ? "static" : "dynamic") + " archive " + archiveFilePath);

-------------

PR: https://git.openjdk.java.net/jdk/pull/5643


More information about the hotspot-runtime-dev mailing list