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)
======================================================================