8295816: jdwp jck tests failing with "FATAL ERROR in native method: JDWP SetTag, jvmtiError=JVMTI_ERROR_WRONG_PHASE(112)"

8295815: misc JDI tests failed with "JDWP exit error JVMTI_ERROR_WRONG_PHASE(112)"

Reviewed-by: sspitsyn, amenkov, dcubed
This commit is contained in:
Chris Plummer 2022-10-25 22:14:36 +00:00
parent e0c29307f7
commit fec61746d1

View File

@ -68,6 +68,21 @@ cbTrackingClassPrepare(jvmtiEnv* jvmti_env, JNIEnv *env, jthread thread, jclass
addPreparedClass(env, klass); addPreparedClass(env, klass);
} }
/*
* It's ok to get WRONG_PHASE errors once the vm is dead. We can just
* ignore the event in that case.
*/
static jboolean
is_wrong_phase(jvmtiError error)
{
if (error == JVMTI_ERROR_WRONG_PHASE) {
JDI_ASSERT(gdata->vmDead);
return JNI_TRUE;
}
return JNI_FALSE;
}
/* /*
* Add a class to the prepared class hash table. * Add a class to the prepared class hash table.
*/ */
@ -78,14 +93,20 @@ addPreparedClass(JNIEnv *env, jclass klass)
char* signature; char* signature;
error = classSignature(klass, &signature, NULL); error = classSignature(klass, &signature, NULL);
if (is_wrong_phase(error)) {
return;
}
if (error != JVMTI_ERROR_NONE) { if (error != JVMTI_ERROR_NONE) {
EXIT_ERROR(error,"signature"); EXIT_ERROR(error,"signature");
} }
if (gdata && gdata->assertOn) { if (gdata->assertOn) {
// Check if already tagged. // Check if already tagged.
jlong tag; jlong tag;
error = JVMTI_FUNC_PTR(trackingEnv, GetTag)(trackingEnv, klass, &tag); error = JVMTI_FUNC_PTR(trackingEnv, GetTag)(trackingEnv, klass, &tag);
if (is_wrong_phase(error)) {
return;
}
if (error != JVMTI_ERROR_NONE) { if (error != JVMTI_ERROR_NONE) {
EXIT_ERROR(error, "Unable to GetTag with class trackingEnv"); EXIT_ERROR(error, "Unable to GetTag with class trackingEnv");
} }
@ -99,6 +120,9 @@ addPreparedClass(JNIEnv *env, jclass klass)
} }
error = JVMTI_FUNC_PTR(trackingEnv, SetTag)(trackingEnv, klass, ptr_to_jlong(signature)); error = JVMTI_FUNC_PTR(trackingEnv, SetTag)(trackingEnv, klass, ptr_to_jlong(signature));
if (is_wrong_phase(error)) {
return;
}
if (error != JVMTI_ERROR_NONE) { if (error != JVMTI_ERROR_NONE) {
jvmtiDeallocate(signature); jvmtiDeallocate(signature);
EXIT_ERROR(error,"SetTag"); EXIT_ERROR(error,"SetTag");