Name: rm29839 Date: 01/30/98
The JDK API documentation indicates that
java.lang.Thread.countStackFrames() can only
be called if the specified thread is
suspended. This would imply that a thread
cannot determine its own frame count:
int i = Thread.currentThread().countStackFrames();
since the currently executing thread cannot be
suspended (duh).
But the above code works, and it is useful, and
I cannot find anything in the source code that
checks to see if the thread is suspended.
Should the above code throw an
IllegalThreadStateException?
Or is the documentation (see below) in error?
http://java.sun.com:80/products/jdk/1.2/docs/api/java.lang.Thread.html#countStackFrames()
This is From the JDK API doc page for java.lang.Thread:
countStackFrames
public native int countStackFrames()
Counts the number of stack frames in this thread. The thread must be suspended.
Returns:
the number of stack frames in this thread.
Throws: IllegalThreadStateException
if this thread is not suspended.
(Review ID: 24246)
======================================================================
- duplicates
-
JDK-4082398 Thread.countStackFrames() does not throw IllegalThreadStateException when thread
- Closed