< prev index next >

src/jdk.management/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java

Print this page

 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package com.sun.management;
 27 
 28 import java.io.IOException;
 29 import java.lang.management.PlatformManagedObject;

 30 
 31 /**
 32  * Diagnostic management interface for the HotSpot Virtual Machine.
 33  *
 34  * <p>The diagnostic MBean is registered to the platform MBeanServer
 35  * as are other platform MBeans.
 36  *
 37  * <p>The {@code ObjectName} for uniquely identifying the diagnostic
 38  * MXBean within an MBeanServer is:
 39  * <blockquote>
 40  *    {@code com.sun.management:type=HotSpotDiagnostic}
 41  * </blockquote>
 42 .*
 43  * It can be obtained by calling the
 44  * {@link PlatformManagedObject#getObjectName} method.
 45  *
 46  * All methods throw a {@code NullPointerException} if any input argument is
 47  * {@code null} unless it's stated otherwise.
 48  *
 49  * @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
 50  */
 51 public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
 52     /**
 53      * Dumps the heap to the {@code outputFile} file in the same
 54      * format as the hprof heap dump.
 55      * <p>
 56      * If this method is called remotely from another process,
 57      * the heap dump output is written to a file named {@code outputFile}
 58      * on the machine where the target VM is running.  If outputFile is
 59      * a relative path, it is relative to the working directory where
 60      * the target VM was started.
 61      *
 62      * @param  outputFile the system-dependent filename

100      * Sets a VM option of the given name to the specified value.
101      * The new value will be reflected in a new {@code VMOption}
102      * object returned by the {@link #getVMOption} method or
103      * the {@link #getDiagnosticOptions} method.  This method does
104      * not change the value of this {@code VMOption} object.
105      *
106      * @param name Name of a VM option
107      * @param value New value of the VM option to be set
108      *
109      * @throws IllegalArgumentException if the VM option of the given name
110      *                                     does not exist.
111      * @throws IllegalArgumentException if the new value is invalid.
112      * @throws IllegalArgumentException if the VM option is not writable.
113      * @throws NullPointerException if name or value is {@code null}.
114      *
115      * @throws  java.lang.SecurityException
116      *     if a security manager exists and the caller does not have
117      *     ManagementPermission("control").
118      */
119     public void setVMOption(String name, String value);
















































120 }

 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package com.sun.management;
 27 
 28 import java.io.IOException;
 29 import java.lang.management.PlatformManagedObject;
 30 import jdk.internal.javac.PreviewFeature;
 31 
 32 /**
 33  * Diagnostic management interface for the HotSpot Virtual Machine.
 34  *
 35  * <p>The diagnostic MBean is registered to the platform MBeanServer
 36  * as are other platform MBeans.
 37  *
 38  * <p>The {@code ObjectName} for uniquely identifying the diagnostic
 39  * MXBean within an MBeanServer is:
 40  * <blockquote>
 41  *    {@code com.sun.management:type=HotSpotDiagnostic}
 42  * </blockquote>
 43  *
 44  * It can be obtained by calling the
 45  * {@link PlatformManagedObject#getObjectName} method.
 46  *
 47  * All methods throw a {@code NullPointerException} if any input argument is
 48  * {@code null} unless it's stated otherwise.
 49  *
 50  * @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
 51  */
 52 public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
 53     /**
 54      * Dumps the heap to the {@code outputFile} file in the same
 55      * format as the hprof heap dump.
 56      * <p>
 57      * If this method is called remotely from another process,
 58      * the heap dump output is written to a file named {@code outputFile}
 59      * on the machine where the target VM is running.  If outputFile is
 60      * a relative path, it is relative to the working directory where
 61      * the target VM was started.
 62      *
 63      * @param  outputFile the system-dependent filename

101      * Sets a VM option of the given name to the specified value.
102      * The new value will be reflected in a new {@code VMOption}
103      * object returned by the {@link #getVMOption} method or
104      * the {@link #getDiagnosticOptions} method.  This method does
105      * not change the value of this {@code VMOption} object.
106      *
107      * @param name Name of a VM option
108      * @param value New value of the VM option to be set
109      *
110      * @throws IllegalArgumentException if the VM option of the given name
111      *                                     does not exist.
112      * @throws IllegalArgumentException if the new value is invalid.
113      * @throws IllegalArgumentException if the VM option is not writable.
114      * @throws NullPointerException if name or value is {@code null}.
115      *
116      * @throws  java.lang.SecurityException
117      *     if a security manager exists and the caller does not have
118      *     ManagementPermission("control").
119      */
120     public void setVMOption(String name, String value);
121 
122     /**
123      * Generate a thread dump to the given file and format. The {@code outputFile}
124      * parameter must be an absolute path.
125      *
126      * <p> The thread dump will include output for all platform threads. It may
127      * include output for some or all virtual threads.
128      *
129      * @implSpec
130      * The default implementation throws {@code UnsupportedOperationException}.
131      *
132      * @apiNote
133      * The output file is required to be an absolute path as the MXBean may be
134      * accessed remotely from a tool or program with a different current user
135      * directory.
136      *
137      * @param  outputFile the path to the file to create
138      * @param  format the format to use (TEXT_PLAIN or JSON)
139      * @throws IllegalArgumentException if the file path is not absolute
140      * @throws IOException if an I/O exception is thrown writing to the file
141      * @throws NullPointerException if either parameter is {@code null}.
142      * @throws SecurityException
143      *         If a security manager is set and its {@link
144      *         SecurityManager#checkWrite(java.lang.String)} method denies write
145      *         access to the file or {@link java.lang.management.ManagementPermission
146      *         ManagementPermission("control")} is denied.
147      * @since 99
148      */
149     @PreviewFeature(feature = PreviewFeature.Feature.VIRTUAL_THREADS)
150     default void dumpThreads(String outputFile, ThreadDumpFormat format) throws IOException {
151         throw new UnsupportedOperationException();
152     }
153 
154     /**
155      * Thread dump format.
156      * @since 99
157      */
158     @PreviewFeature(feature = PreviewFeature.Feature.VIRTUAL_THREADS)
159     public static enum ThreadDumpFormat {
160         /**
161          * Plain text format.
162          */
163         TEXT_PLAIN,
164         /**
165          * JSON (JavaScript Object Notation) format.
166          */
167         JSON,
168     }
169 }
< prev index next >