@@ -154,7 +154,7 @@ void test_GetLocalObject(jvmtiEnv* jvmti, JNIEnv* env, int depth) {
154
154
jobject obj;
155
155
char * errMsg;
156
156
157
- printf (" AGENT: calling GetLocalObject()\n " );
157
+ printf (" AGENT: calling GetLocalObject() with depth %d \n " , depth );
158
158
err = jvmti->GetLocalObject (target_thread, depth, 0 , &obj);
159
159
errMsg = GetErrorMessage (jvmti, err);
160
160
printf (" AGENT: GetLocalObject() result code %s (%d)\n " , errMsg != NULL ? errMsg : " N/A" , err);
@@ -166,9 +166,13 @@ void test_GetLocalObject(jvmtiEnv* jvmti, JNIEnv* env, int depth) {
166
166
// If the target thread wins the race we can get errors because we
167
167
// don't find a frame at the given depth or we find a non-java frame
168
168
// there (e.g. native frame). This is expected.
169
+ // JVMTI_ERROR_INVALID_SLOT can occur also because the target thread is
170
+ // running and the GetLocalObject() call might coincidentally refer to the
171
+ // frame of a static method without parameters.
169
172
if (err != JVMTI_ERROR_NONE &&
170
173
err != JVMTI_ERROR_NO_MORE_FRAMES &&
171
- err != JVMTI_ERROR_OPAQUE_FRAME) {
174
+ err != JVMTI_ERROR_OPAQUE_FRAME &&
175
+ err != JVMTI_ERROR_INVALID_SLOT) {
172
176
ShowErrorMessage (jvmti, err, " AgentThreadLoop: error in JVMTI GetLocalObject" );
173
177
env->FatalError (" AgentThreadLoop: error in JVMTI GetLocalObject\n " );
174
178
}
@@ -260,7 +264,7 @@ AgentThreadLoop(jvmtiEnv * jvmti, JNIEnv* env, void * arg) {
260
264
// It notifies the agent to do the GetLocalObject() call and then races
261
265
// it to make its stack not walkable by returning from the native call.
262
266
JNIEXPORT void JNICALL
263
- Java_GetLocalWithoutSuspendTest_notifyAgentToGetLocal (JNIEnv *env, jclass cls, jint depth, jlong waitCycles) {
267
+ Java_GetLocalWithoutSuspendTest_notifyAgentToGetLocal (JNIEnv *env, jclass cls, jint depth, jint waitCycles) {
264
268
monitor_enter (jvmti, env, AT_LINE);
265
269
266
270
// Set depth_for_get_local and notify agent that the target thread is ready for the GetLocalObject() call
0 commit comments