Hello,

I'd like to propose a new revision of the JVMTI spec, 1.2.1 to be implemented by Hotspot in JDK 7, with the addition of a new method, GetThisObject() (defined below). This new function would be part of the 'Local Variable" set of functions. The motivation for this addition is better filtering of JDI events in the situations where events are raised in the context of a native method. This function would use a new slot in the function pointer table, so the 1.2 version of JVMTI will be backward-compatible with version 1.1. Clients using JVMTI 1.1 or 1.0 would be unaffected by this change, other than observing that GetVersion() function returns the new revision number.

Comments?  Suggestions? Complaints?

Get This Object

jvmtiError
GetThisObject(jvmtiEnv* env,
            jthread thread,
            jint depth,
            jobject* value_ptr)
This function can be used to retrieve the value of the local object variable at slot 0 (the "this" object) from non-static frames. This function can retrieve the "this" object from native activations, whereas GetLocalObject() would return JVMTI_ERROR_OPAQUE_FRAME for those frames.

Phase   Callback Safe   Position        Since
may only be called during the live phase         No     155     1.2

Capabilities
Optional Functionality: might not be implemented for all virtual machines. The following capability (as returned by GetCapabilities) must be true to use this function.
Capability       Effect
can_access_local_variables       Can set and get local variables

Parameters
Name     Type    Description
thread jthread The thread of the frame containing the variable's value. If thread is NULL, the current thread is used.
depth   jint     The depth of the frame containing the variable's value.
value_ptr       jobject*         On return, points to the variable's value.

Agent passes a pointer to a jobject. On return, the jobject has been set. The object returned by value_ptr is a JNI local reference and must be managed.

Errors
This function returns either a universal error or one of the following errors
Error    Description
JVMTI_ERROR_MUST_POSSESS_CAPABILITY The environment does not possess the capability can_access_local_variables. Use AddCapabilities. JVMTI_ERROR_INVALID_SLOT If the activation corresponds to a static method.
JVMTI_ERROR_INVALID_THREAD      thread is not a thread object.
JVMTI_ERROR_THREAD_NOT_ALIVE thread is not live (has not been started or is now dead).
JVMTI_ERROR_ILLEGAL_ARGUMENT    depth is less than zero.
JVMTI_ERROR_NO_MORE_FRAMES There are no stack frames at the specified depth.
JVMTI_ERROR_NULL_POINTER        value_ptr is NULL.

Reply via email to