How to intercept system calls in JVM?
843829Feb 11 2009 — edited Jun 25 2009Hi, everyone. I am looking for a way to intercept system calls in JVM, a way do something like ptrace does in Linux. Because I wanna log all function calls a specified application made, and I may modify the arguments and the return value.
And then i search the internet but nothing found except this article:
[ http://java.sun.com/developer/technicalArticles/Programming/jvmti/#Authors| http://java.sun.com/developer/technicalArticles/Programming/jvmti/#Authors]
It's seems that JVMTI is a perfect tools to manipulate Java VM and i can achieve my goal with it. I download the sample code you written and modify a bit to adopt my environment (I use Linux and Sun JDK 6). It works well.
And then I add a function to get stacktrace like the case in your article. I also read the sample code in JVMIT Refenerce, but it doesn't work.
So, I am puzzled. I wanna know is there any way to intercept system calls in JVM? If JVMTI can do it, is there any tutorial or sample code to review? And, is that possible to use this way in J2ME?
Thanks a lot :)
Best Regard.