[Soot-list] public synchronized native instrumentation?

Ondrej Lhotak olhotak at sable.mcgill.ca
Fri Dec 17 11:42:12 EST 2004


On Fri, Dec 10, 2004 at 02:33:40PM -0800, ross at sourcelabs.com wrote:
> I have a need to dynamically instrument a non-static method that is
> declared "public synchronized native" in order to run code after each
> method invocation. I'm new to Java bytecode and its instrumentation and I
> don't immediately see how this can be done.

If I understand correctly, you want to insert some code at the end of a
native method. Since the body of a native method is not bytecode, you
cannot add bytecode to it. One thing you can do is to write a non-native
replacement for your native method which calls a renamed version of the
native method and then executes the instrumentation code. Another
possible approach would be to put the instrumentation code after
every call to the native method, rather than in the method itself.
However, with this approach, you have to be careful because of dynamic
dispatch: depending on the type of the receiver, a different method
could be called from the call site.

Ondrej

> Can someone point me in the right direction if this is possible?
> 
> Thanks,
> Ross Jekel
> SourceLabs, Inc
> 
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://www.sable.mcgill.ca/mailman/listinfo/soot-list
> 


More information about the Soot-list mailing list