< prev index next >

src/java.base/share/classes/jdk/internal/vm/ThreadSnapshot.java

Print this page
*** 28,11 ***
  import java.util.stream.Stream;
  
  /**
   * Represents a snapshot of information about a Thread.
   */
! class ThreadSnapshot {
      private static final StackTraceElement[] EMPTY_STACK = new StackTraceElement[0];
      private static final ThreadLock[] EMPTY_LOCKS = new ThreadLock[0];
  
      // filled by VM
      private String name;
--- 28,11 ---
  import java.util.stream.Stream;
  
  /**
   * Represents a snapshot of information about a Thread.
   */
! public class ThreadSnapshot {
      private static final StackTraceElement[] EMPTY_STACK = new StackTraceElement[0];
      private static final ThreadLock[] EMPTY_LOCKS = new ThreadLock[0];
  
      // filled by VM
      private String name;

*** 52,18 ***
  
      private ThreadSnapshot() {}
  
      /**
       * Take a snapshot of a Thread to get all information about the thread.
!      * Return null if a ThreadSnapshot is not created, for example if the
-      * thread has terminated.
-      * @throws UnsupportedOperationException if not supported by VM
       */
!     static ThreadSnapshot of(Thread thread) {
          ThreadSnapshot snapshot = create(thread);
          if (snapshot == null) {
!             return null; // thread terminated
          }
          if (snapshot.stackTrace == null) {
              snapshot.stackTrace = EMPTY_STACK;
          }
          if (snapshot.locks != null) {
--- 52,16 ---
  
      private ThreadSnapshot() {}
  
      /**
       * Take a snapshot of a Thread to get all information about the thread.
!      * Return null if the thread is not alive.
       */
!     public static ThreadSnapshot of(Thread thread) {
          ThreadSnapshot snapshot = create(thread);
          if (snapshot == null) {
!             return null; // thread not alive
          }
          if (snapshot.stackTrace == null) {
              snapshot.stackTrace = EMPTY_STACK;
          }
          if (snapshot.locks != null) {

*** 96,11 ***
      }
  
      /**
       * Returns the thread stack trace.
       */
!     StackTraceElement[] stackTrace() {
          return stackTrace;
      }
  
      /**
       * Returns the thread's parkBlocker.
--- 94,11 ---
      }
  
      /**
       * Returns the thread stack trace.
       */
!     public StackTraceElement[] stackTrace() {
          return stackTrace;
      }
  
      /**
       * Returns the thread's parkBlocker.
< prev index next >