instrumenting java classes INSIDE the jvm

Tony Guan guanxiaohua at
Sun Nov 21 23:19:07 PST 2010

Dear all,

I want to do something special once a method M is called for some type
of class C, mainly to changed the policy of gc.

Currently, I am intercepting SharedRuntime::dtrace_method_entry() to
insert my own code inside hotspot. While this works, the performance
is really terrible. Because I have to compare each method call with
the right one, and the string comparison happens for every method call
under the class type C.

So I am looking for a way to insert some code at the beginning of a
CERTAIN method call, to avoid the need of instrumenting or monitoring
EVERY method call.

I understand that this can be done with some java agent, but my
implementation need to be able to call into the JVM, so that the GC
behavior can be changed. That means I need to let the hotspot know
once method M of class C is called, not a standalone java program.

Currently I want to mark the class and the method upon class loading,
and to do the comparison in SharedRuntime::dtrace_method_entry(). This
should avoid the need to do the string comparison, but still need to
monitor every method call, which is an overhead that we really want to
get rid of.

Thanks a lot!


More information about the hotspot-runtime-dev mailing list