< prev index next >

jdk/src/java.base/share/classes/java/lang/Thread.java

Print this page

        

@@ -1327,15 +1327,13 @@
     }
 
     /**
      * Prints a stack trace of the current thread to the standard error stream.
      * This method is used only for debugging.
-     *
-     * @see     Throwable#printStackTrace()
      */
     public static void dumpStack() {
-        new Exception("Stack trace").printStackTrace();
+        StackStreamFactory.makeStackTrace().printStackTrace(System.err);
     }
 
     /**
      * Marks this thread as either a {@linkplain #isDaemon daemon} thread
      * or a user thread. The Java Virtual Machine exits when the only

@@ -1554,11 +1552,11 @@
                 stackTrace = EMPTY_STACK_TRACE;
             }
             return stackTrace;
         } else {
             // Don't need JVM help for current thread
-            return (new Exception()).getStackTrace();
+            return StackStreamFactory.makeStackTrace().getStackTraceElements();
         }
     }
 
     /**
      * Returns a map of stack traces for all live threads.
< prev index next >