- All Superinterfaces:
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.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThread dump format. -
Method Summary
Modifier and TypeMethodDescriptionvoidDumps the heap to theoutputFilefile in the same format as the hprof heap dump.default voiddumpThreads(String outputFile, HotSpotDiagnosticMXBean.ThreadDumpFormat format) Generate a thread dump to the given file in the given format.Returns a list ofVMOptionobjects for all diagnostic options.getVMOption(String name) Returns aVMOptionobject for a VM option of the given name.voidsetVMOption(String name, String value) Sets a VM option of the given name to the specified value.Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
-
Method Details
-
dumpHeap
Dumps the heap to theoutputFilefile 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
outputFileon 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- the system-dependent filenamelive- iftruedump only live objects i.e. objects that are reachable from others- Throws:
IOException- if theoutputFilealready exists, cannot be created, opened, or written to.UnsupportedOperationException- if this operation is not supported.IllegalArgumentException- ifoutputFiledoes not end with ".hprof" suffix.NullPointerException- ifoutputFileisnull.SecurityException- If a security manager exists and itsSecurityManager.checkWrite(java.lang.String)method denies write access to the named file or the caller does not have ManagmentPermission("control").
-
getDiagnosticOptions
Returns a list ofVMOptionobjects for all diagnostic options. A diagnostic option is awriteableVM option that can be set dynamically mainly for troubleshooting and diagnosis.- Returns:
- a list of
VMOptionobjects for all diagnostic options.
-
getVMOption
Returns aVMOptionobject for a VM option of the given name.- Returns:
- a
VMOptionobject for a VM option of the given name. - Throws:
NullPointerException- if name isnull.IllegalArgumentException- if a VM option of the given name does not exist.
-
setVMOption
Sets a VM option of the given name to the specified value. The new value will be reflected in a newVMOptionobject returned by thegetVMOption(java.lang.String)method or thegetDiagnosticOptions()method. This method does not change the value of thisVMOptionobject.- Parameters:
name- Name of a VM optionvalue- New value of the VM option to be set- Throws:
IllegalArgumentException- if the VM option of the given name does not exist.IllegalArgumentException- if the new value is invalid.IllegalArgumentException- if the VM option is not writable.NullPointerException- if name or value isnull.SecurityException- if a security manager exists and the caller does not have ManagementPermission("control").
-
dumpThreads
default void dumpThreads(String outputFile, HotSpotDiagnosticMXBean.ThreadDumpFormat format) throws IOException Generate a thread dump to the given file in the given format. TheoutputFileparameter must be an absolute path to a file that does not exist.The thread dump will include output for all platform threads. It may include output for some or all virtual threads.
- 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.
- Implementation Requirements:
- The default implementation throws
UnsupportedOperationException. - Parameters:
outputFile- the path to the file to createformat- the format to use- Throws:
IllegalArgumentException- if the file path is not absoluteIOException- if the file already exists or an I/O exception is thrown writing to the fileNullPointerException- if either parameter isnullSecurityException- if a security manager is set and itsSecurityManager.checkWrite(java.lang.String)method denies write access to the file orManagementPermission("control")is deniedUnsupportedOperationException- if this operation is not supported- Since:
- 21
-