2 Replies Latest reply: Oct 10, 2007 2:46 AM by 843810 RSS

    Obtaining access to current thread stackframes?

    843810
      I have a method that logs on entry (based on a flag), and I would like
      to be able to identify the caller in the trace. Now, I can use
      Thread.getStackTrace() to get the static thread stack, from which I
      can get the invoking class and method. However, I would like to get
      hold of the 'this' object reference of the immediate parent stack
      frame, so that I can identify the instance of the caller. Is there a
      way to do this? The JVMTI seems to be written to access a
      different JVM, and I can't see a way to put it to use.

      This code does not have to be very efficient, as it will only be
      turned on rarely in fault isolation. Any help is greatly appreciated.