Introduced:
The above discusses how an agent can access a VM using an environment pointer (management Class), which discusses how to manage objects.
Category 9: Object management
A.getobjectsize. Gets the size of the object,
Jvmtierrorgetobjectsize (jvmtienv* env, Jobject object, jlong* size_ptr)
Note that this is not true size, which is just a pre-estimate obtained from the object's definition code.
B.getobjecthashcode. Gets the hash value of the object.
Jvmtierrorgetobjecthashcode (jvmtienv* env, Jobject object, jint* hash_code_ptr)
C.getobjectmonitorusage. Gets the monitor for the object.
typedef struct {Jthread owner; Jint Entry_count; Jint Waiter_count; Jthread* Waiters; Jint Notify_waiter_count; jthread* Notify_waiters;} Jvmtimonitorusage;
Jvmtierrorgetobjectmonitorusage (jvmtienv* env, Jobject object, jvmtimonitorusage* info_ptr)
This method is worth saying, as you can see from the return value, that it can contain the following information for the object's monitor:
(1) The thread on which the monitor resides
(2) The number of times a thread has entered the monitor
(3) The number of threads waiting to have this monitor.
(4) Wait for the list of threads that have this monitor.
(5) The number of threads waiting to be notified by this monitor.
(6) A list of threads waiting to be notified by this monitor.
This article is from the "cohesion of parallel Lines" blog, please be sure to keep this source http://supercharles888.blog.51cto.com/609344/1587822
JPDA Architecture Research 14-agent using environment pointers to access VMs (Object Management chapter)