APIdia Launch Partner
Top Description Inners Methods
com.sun.management

public Interface HotSpotDiagnosticMXBean

extends PlatformManagedObject
Known Direct Implementers
com.sun.management.internal.HotSpotDiagnostic
Imports
java.io.IOException, java.lang.management.PlatformManagedObject

Diagnostic management interface for the HotSpot Virtual Machine.

The diagnostic MBean is registered to the platform MBeanServer as are other platform MBeans.

The ObjectName for uniquely identifying the diagnostic MXBean within an MBeanServer is:

com.sun.management:type=HotSpotDiagnostic
It can be obtained by calling the PlatformManagedObject#getObjectName method. All methods throw a NullPointerException if any input argument is null unless it's stated otherwise.
Since
1.6
See Also
java.lang.management.ManagementFactory#getPlatformMXBeans(Class)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Method Summary

Modifier and TypeMethod and Description
public void
dumpHeap(String
the system-dependent filename
outputFile
,
boolean
if true dump only live objects i.e. objects that are reachable from others
live
)

Dumps the heap to the outputFile file in the same format as the hprof heap dump.

public default void
dumpThreads(String
the path to the file to create
outputFile
,
HotSpotDiagnosticMXBean.ThreadDumpFormat
the format to use
format
)

Generate a thread dump to the given file in the given format.

public List<VMOption>

Returns:

a list of VMOption objects for all diagnostic options.
getDiagnosticOptions
()

Returns a list of VMOption objects for all diagnostic options.

public VMOption

Returns:

a VMOption object for a VM option of the given name.
getVMOption
(String name)

Returns a VMOption object for a VM option of the given name.

public void
setVMOption(String
Name of a VM option
name
,
String
New value of the VM option to be set
value
)

Sets a VM option of the given name to the specified value.

Inherited from java.lang.management.PlatformManagedObject:
getObjectName

Method Detail

dumpHeapback to summary
public void dumpHeap(String outputFile, boolean live) throws IOException

Dumps the heap to the outputFile file in the same format as the hprof heap dump.

If this method is called remotely from another process, the heap dump output is written to a file named outputFile on the machine where the target VM is running. If outputFile is a relative path, it is relative to the working directory where the target VM was started.

Parameters
outputFile:String

the system-dependent filename

live:boolean

if true dump only live objects i.e. objects that are reachable from others

Exceptions
IOException:
if the outputFile already exists, cannot be created, opened, or written to.
UnsupportedOperationException:
if this operation is not supported.
IllegalArgumentException:
if outputFile does not end with ".hprof" suffix.
NullPointerException:
if outputFile is null.
dumpThreadsback to summary
public default void dumpThreads(String outputFile, HotSpotDiagnosticMXBean.ThreadDumpFormat format) throws IOException

Generate a thread dump to the given file in the given format. The outputFile parameter must be an absolute path to a file that does not exist.

When the format is specified as JSON, the thread dump is generated as JSON text in the JSON Thread Dump Format.

The thread dump will include output for all platform threads. It may include output for some or all virtual threads.

Implementation Specification

The default implementation throws UnsupportedOperationException.

API Note

The output file is required to be an absolute path as the MXBean may be accessed remotely from a tool or program with a different current working directory.

Parameters
outputFile:String

the path to the file to create

format:HotSpotDiagnosticMXBean.ThreadDumpFormat

the format to use

Exceptions
IOException:
if the file already exists or an I/O exception is thrown writing to the file
IllegalArgumentException:
if the file path is not absolute
NullPointerException:
if either parameter is null
UnsupportedOperationException:
if this operation is not supported
Since
21
getDiagnosticOptionsback to summary
public List<VMOption> getDiagnosticOptions()

Returns a list of VMOption objects for all diagnostic options. A diagnostic option is a writeable VM option that can be set dynamically mainly for troubleshooting and diagnosis.

Returns:List<VMOption>

a list of VMOption objects for all diagnostic options.

getVMOptionback to summary
public VMOption getVMOption(String name)

Returns a VMOption object for a VM option of the given name.

Returns:VMOption

a VMOption object for a VM option of the given name.

Exceptions
NullPointerException:
if name is null.
IllegalArgumentException:
if a VM option of the given name does not exist.
setVMOptionback to summary
public void setVMOption(String name, String value)

Sets a VM option of the given name to the specified value. The new value will be reflected in a new VMOption object returned by the getVMOption method or the getDiagnosticOptions method. This method does not change the value of this VMOption object.

Parameters
name:String

Name of a VM option

value:String

New value of the VM option to be set

Exceptions
IllegalArgumentException:
  • if the VM option of the given name does not exist.
  • if the new value is invalid.
  • if the VM option is not writable.
NullPointerException:
if name or value is null.
com.sun.management back to summary

public final Enum HotSpotDiagnosticMXBean.ThreadDumpFormat

extends Enum<HotSpotDiagnosticMXBean.ThreadDumpFormat>
Class Inheritance

Thread dump format.
Since
21

Field Summary

Modifier and TypeField and Description
public static final HotSpotDiagnosticMXBean.ThreadDumpFormat
JSON

JSON (JavaScript Object Notation) format.

public static final HotSpotDiagnosticMXBean.ThreadDumpFormat
TEXT_PLAIN

Plain text format.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static HotSpotDiagnosticMXBean.ThreadDumpFormat
public static HotSpotDiagnosticMXBean.ThreadDumpFormat[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

JSONback to summary
public static final HotSpotDiagnosticMXBean.ThreadDumpFormat JSON

JSON (JavaScript Object Notation) format.

External Specification
https://datatracker.ietf.org/doc/html/rfc8259
TEXT_PLAINback to summary
public static final HotSpotDiagnosticMXBean.ThreadDumpFormat TEXT_PLAIN

Plain text format.

Constructor Detail

ThreadDumpFormatback to summary
private ThreadDumpFormat()

Method Detail

valueOfback to summary
public static HotSpotDiagnosticMXBean.ThreadDumpFormat valueOf(String name)
valuesback to summary
public static HotSpotDiagnosticMXBean.ThreadDumpFormat[] values()