开发者

How to track locking events in JVMTI

JVMTI offers the events ContendedMonitorEnter and ContendedMonitorEntered to detect events related to the use of synchronized. synchronized is nothing else, but a ReentrantLock.

Now I would like to track also events related to the lock structure: ReentrantLock. I 开发者_JAVA技巧could hook to method entry/exit of its lock() and unlock() events. However, these event hooks don't provide any information about the object they were invoked on. Thus I cannot distinguish between different ReentrantLock and thus cannot log any information about which lock is currently locked.

Is there any other way to keep track of this?


You'll have to instrument the classes being loaded by yourself. This is rather complicated, but fortunately we have java_crw_demo.c which is supplied (alongside with other helpful examples) together with JDK. There you can find an implementation that does some basic kinds of instrumentation. You can easily modify it to do the job. I am doing this now for some academic student project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜