[dtrace-discuss] Using dtrace to monitor native calls into Java code

Eric Bodden
Wed, 10 Feb 2010 14:55:37 -0000

Hi again.

> However in this case I doubt that there''s an appropriate code path
in the
> JVM that can be instrumented to give you this information reliably.
?Hotspot
> tries to arrange things so that executing Java code will directly call the
> target method without dropping into the VM, even for reflective calls.

Do you mean these GeneratedMethodAccessors etc.? I know that the JDK
generates those sometimes, but not always, depending on how frequently
the method is invoked (usually more than 15 times). If the method is
called rather infrequently, then reflection appears to go through a
native interface. Ideally, I would like to trace both.

> If you''re up for an adventure, one attempt may be to download the
jdk7
> sources and instrument the java.lang.reflect code with the Java user-level
> tracing calls in com.sun.tracing.

Hmm, I was trying to avoid that but it may be an option of last resort...

> Of course, as with any probes, the ustack() (or jstack()) actions should
> give you a full stack trace. ?(although there is an issue getting Java
> frames on some architectures if you''re using the server compiler).

Oh, I did not know that feature. That may end up being useful. Thanks again!

Eric