instrumenting java classes INSIDE the jvm
poonam.bajaj at oracle.com
Mon Nov 22 00:25:53 PST 2010
Have you explored doing this using Dynamic Bytecode Instrumentation
using JVMTI's redefineClass(Class classes*, *byte newBC) method.
On 11/22/2010 12:49 PM, Tony Guan wrote:
> 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!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-runtime-dev