< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 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

 99      * object returned by the {@link #getVMOption} method or
100      * the {@link #getDiagnosticOptions} method.  This method does
101      * not change the value of this {@code VMOption} object.
102      *
103      * @param name Name of a VM option
104      * @param value New value of the VM option to be set
105      *
106      * @throws IllegalArgumentException if the VM option of the given name
107      *                                     does not exist.
108      * @throws IllegalArgumentException if the new value is invalid.
109      * @throws IllegalArgumentException if the VM option is not writable.
110      * @throws NullPointerException if name or value is {@code null}.
111      */
112     public void setVMOption(String name, String value);
113 
114     /**
115      * Generate a thread dump to the given file in the given format. The
116      * {@code outputFile} parameter must be an absolute path to a file that
117      * does not exist.
118      *







119      * <p> The thread dump will include output for all platform threads. It may
120      * include output for some or all virtual threads.
121      *
122      * @implSpec
123      * The default implementation throws {@code UnsupportedOperationException}.
124      *
125      * @apiNote
126      * The output file is required to be an absolute path as the MXBean may be
127      * accessed remotely from a tool or program with a different current working
128      * directory.
129      *
130      * @param  outputFile the path to the file to create
131      * @param  format the format to use
132      * @throws IllegalArgumentException if the file path is not absolute
133      * @throws IOException if the file already exists or an I/O exception is
134      *         thrown writing to the file
135      * @throws NullPointerException if either parameter is {@code null}
136      * @throws UnsupportedOperationException if this operation is not supported
137      * @since 21
138      */
139     default void dumpThreads(String outputFile, ThreadDumpFormat format) throws IOException {
140         throw new UnsupportedOperationException();
141     }
142 
143     /**
144      * Thread dump format.
145      * @since 21
146      */
147     public static enum ThreadDumpFormat {
148         /**
149          * Plain text format.
150          */
151         TEXT_PLAIN,
152         /**
153          * JSON (JavaScript Object Notation) format.

154          */
155         JSON,
156     }
157 }

  1 /*
  2  * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 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

 99      * object returned by the {@link #getVMOption} method or
100      * the {@link #getDiagnosticOptions} method.  This method does
101      * not change the value of this {@code VMOption} object.
102      *
103      * @param name Name of a VM option
104      * @param value New value of the VM option to be set
105      *
106      * @throws IllegalArgumentException if the VM option of the given name
107      *                                     does not exist.
108      * @throws IllegalArgumentException if the new value is invalid.
109      * @throws IllegalArgumentException if the VM option is not writable.
110      * @throws NullPointerException if name or value is {@code null}.
111      */
112     public void setVMOption(String name, String value);
113 
114     /**
115      * Generate a thread dump to the given file in the given format. The
116      * {@code outputFile} parameter must be an absolute path to a file that
117      * does not exist.
118      *
119      * <p> When the format is specified as {@link ThreadDumpFormat#JSON JSON}, the
120      * thread dump is generated in JavaScript Object Notation.
121      * <a href="doc-files/threadDump.schema.json">threadDump.schema.json</a>
122      * describes the thread dump format in draft
123      * <a href="https://tools.ietf.org/html/draft-json-schema-language-02">
124      * JSON Schema Language version 2</a>.
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 working
135      * directory.
136      *
137      * @param  outputFile the path to the file to create
138      * @param  format the format to use
139      * @throws IllegalArgumentException if the file path is not absolute
140      * @throws IOException if the file already exists or an I/O exception is
141      *         thrown writing to the file
142      * @throws NullPointerException if either parameter is {@code null}
143      * @throws UnsupportedOperationException if this operation is not supported
144      * @since 21
145      */
146     default void dumpThreads(String outputFile, ThreadDumpFormat format) throws IOException {
147         throw new UnsupportedOperationException();
148     }
149 
150     /**
151      * Thread dump format.
152      * @since 21
153      */
154     public static enum ThreadDumpFormat {
155         /**
156          * Plain text format.
157          */
158         TEXT_PLAIN,
159         /**
160          * JSON (JavaScript Object Notation) format.
161          * @spec https://datatracker.ietf.org/doc/html/rfc8259 JavaScript Object Notation
162          */
163         JSON,
164     }
165 }
< prev index next >