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

Thread.countStackFrames() documentation is wrong (I hope)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • docs
    • generic
    • generic



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

            asommere Alan Sommerer (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: