Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4812982

(spec thread) Implement Thread.printStackTrace and friends and then deprecate Thread.dumpStack

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.1
    • core-libs
    • x86
    • windows_xp



      Name: nt126004 Date: 02/04/2003


      DESCRIPTION OF THE PROBLEM :
      I find it hard to remember which way to print a stack trace depending on the object I have to print the stack trace from. Thread.dumpStack() and Throwable.printStackTrace() have the same symantics. Since consistency in an API is a Good Thing (TM) (See Joshua Bloch's 'Effective Java' for
      more detailed logic), I would like to see:

          Thread.dumpStack()

      deprecated, and:

          Thread.printStackTrace()

      added to the Thread API. This could be further enhanced by duplicating all of the Throwable.xxxStackTrace methods in the Thread class:

          Thread.getStackTrace()
          Thread.printStackTrace(PrintStream s)
          Thread.printStackTrace(PrintWriter s)

      (although I think implementing Thread.setStackTrace() is
      probably a bad idea!)

      This change would make the Java API much easier to use,
      since I find it impossible to remember which method
      (printStackTrace? dumpStackTrace? dumpStack? printStack?),
      is on which class.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args) {
        try {
          ; /* do something */
        } catch (Throwable t) {
          /* these two calls have the same symantics. they should be named the same */
          t.printStackTrace();
          Thread.dumpStack();
        }
      }
      ---------- END SOURCE ----------
      (Review ID: 180193)
      ======================================================================

            psoper Pete Soper (Inactive)
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: