Get objects involved in Java stacktrace

I can restore the current stacktrace using Thread.currentThread().getStackTrace() , but this only gives me the classes involved in the call. Is it possible to restore objects involved in call tracing? Maybe some kind of library that allows me to return objects from a heap?

I have a problem that requires me to return to the Spring bean, which indirectly created an object where I request a stack trace.

UPDATE If Java does not have a built-in tool, I am looking for a built-in library that can do this for me at runtime.

+6
source share
3 answers

This is a very interesting idea, but, unfortunately, in general, no , you could not, it is impossible.

UPD: One of the reasons why the answer is “no” is the fact that, if possible, then there should be a list of links to all created objects. But in this case, Java GC will not work at all.

+1
source

You can try housemd . It is designed by @alibaba engineer and is safe to use even in a production environment, for example. taobao.com.

Its function includes:

 Display object field value Output invocation stack trace 

Below is an example screenshot: enter image description here

0
source

Try the Eclipse debugger to see the meaning of the objects used in a particular method. Place breakpoints on the line where you want to pause the program.

0
source

All Articles