Compatibility Risk Description:Only adds additional flag to jcmd GC.heap_dump.
Interface Kind:add/remove/modify command line option
Add an option to the
jcmd GC.heap_dump command to allow it overwrite an existing file.
The GC.heap_dump command expects to create a new file for heap dump and it bails out if the target file exists.
A user may want to overwrite the existing target file.
Also, on many operating systems it is possible to create special file-like objects, which are represented by files on the filesystem. Such file-like objects in many aspects behave like regular files. Now a file-like object can be provided as the target to GC.heap_dump, but it fails since the target already exists. If GC.heap_dump has an option to overwrite the target file, it will be possible to use a file-like object for the heap dump. Missing option to overwrite the target file is the only blocker to use file-like objects with GC.heap_dump.
Add an option to overwrite an existing target file specified for the diagnostic command GC.heap_dump.
The option enables the transparent use of file-like objects with GC.heap_dump without any additional change in the JVM.
Add a boolean option
overwrite to the GC.heap_dump diagnostic command.
If it is specified and the target file exists, the file will be rewritten.
If it is specified and the target file does not exist, it will be created.
If the option is not specified, the behavior is not changed, and an attempt to use an existing file will fail.
jcmd <pid|main class> GC.heap_dump -overwrite <existing-file-name>