pre/post method call interceptor for every java method without java code change

Christian Thalinger christian.thalinger at oracle.com
Wed May 11 03:47:51 PDT 2011


On May 11, 2011, at 12:09 PM, Balázs Galambos wrote:
> Hello
> 
> I am trying to modify current stack trace creation and exception
> handling of java.( to make Thread.dumpthreads more informative.)
> I am looking for the point where the a new stacktraceelement is put
> into the stack trace when a method is executed, and where it is
> removed after finishing with it. I want to create a pre method
> interceptor and a post method interceptor, that are called for every
> method it finds during execution, without having to change all my java
> source. In these interceptors I want to add some extra info to the
> stack trace.
> 
> I think the answer is somewhere in JVM hotspot.
> javaCallWrapper seems to do what I need, but I cannot find where is
> the point when it adds/removes stack trace info.
> 
> I have found some constructors of stack trace elements are located in
> javaClasses.cpp (java_lang_Throwable::fill_in_stack_trace..) but I am
> not sure which one is used.

Before messing around with the stacktrace creation in HotSpot you should ask yourself if it's possible to do what you want with a Java agent (or JVMTI).  It would be much easier.

-- Christian


More information about the hotspot-dev mailing list