< prev index next >

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

Print this page
*** 25,10 ***
--- 25,11 ---
  
  package com.sun.management;
  
  import java.io.IOException;
  import java.lang.management.PlatformManagedObject;
+ import jdk.internal.javac.PreviewFeature;
  
  /**
   * Diagnostic management interface for the HotSpot Virtual Machine.
   *
   * <p>The diagnostic MBean is registered to the platform MBeanServer

*** 37,11 ***
   * <p>The {@code ObjectName} for uniquely identifying the diagnostic
   * MXBean within an MBeanServer is:
   * <blockquote>
   *    {@code com.sun.management:type=HotSpotDiagnostic}
   * </blockquote>
! .*
   * It can be obtained by calling the
   * {@link PlatformManagedObject#getObjectName} method.
   *
   * All methods throw a {@code NullPointerException} if any input argument is
   * {@code null} unless it's stated otherwise.
--- 38,11 ---
   * <p>The {@code ObjectName} for uniquely identifying the diagnostic
   * MXBean within an MBeanServer is:
   * <blockquote>
   *    {@code com.sun.management:type=HotSpotDiagnostic}
   * </blockquote>
!  *
   * It can be obtained by calling the
   * {@link PlatformManagedObject#getObjectName} method.
   *
   * All methods throw a {@code NullPointerException} if any input argument is
   * {@code null} unless it's stated otherwise.

*** 115,6 ***
--- 116,54 ---
       * @throws  java.lang.SecurityException
       *     if a security manager exists and the caller does not have
       *     ManagementPermission("control").
       */
      public void setVMOption(String name, String value);
+ 
+     /**
+      * Generate a thread dump to the given file and format. The {@code outputFile}
+      * parameter must be an absolute path.
+      *
+      * <p> The thread dump will include output for all platform threads. It may
+      * include output for some or all virtual threads.
+      *
+      * @implSpec
+      * The default implementation throws {@code UnsupportedOperationException}.
+      *
+      * @apiNote
+      * 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 user
+      * directory.
+      *
+      * @param  outputFile the path to the file to create
+      * @param  format the format to use (TEXT_PLAIN or JSON)
+      * @throws IllegalArgumentException if the file path is not absolute
+      * @throws IOException if an I/O exception is thrown writing to the file
+      * @throws NullPointerException if either parameter is {@code null}.
+      * @throws SecurityException
+      *         If a security manager is set and its {@link
+      *         SecurityManager#checkWrite(java.lang.String)} method denies write
+      *         access to the file or {@link java.lang.management.ManagementPermission
+      *         ManagementPermission("control")} is denied.
+      * @since 99
+      */
+     @PreviewFeature(feature = PreviewFeature.Feature.VIRTUAL_THREADS)
+     default void dumpThreads(String outputFile, ThreadDumpFormat format) throws IOException {
+         throw new UnsupportedOperationException();
+     }
+ 
+     /**
+      * Thread dump format.
+      * @since 99
+      */
+     @PreviewFeature(feature = PreviewFeature.Feature.VIRTUAL_THREADS)
+     public static enum ThreadDumpFormat {
+         /**
+          * Plain text format.
+          */
+         TEXT_PLAIN,
+         /**
+          * JSON (JavaScript Object Notation) format.
+          */
+         JSON,
+     }
  }
< prev index next >