extern"C" JNIEXPORT void JNICALL Java_art_Test928_doOtherThreadTest(JNIEnv* env, jclass klass) {
size_t start_other_thread_count = gGlobalRefCount; // Make sure it still works even on another thread.
jobject global = env->NewGlobalRef(klass);
CHECK_EQ(start_other_thread_count + 1, gGlobalRefCount);
env->DeleteGlobalRef(global);
}
extern"C" JNIEXPORT void JNICALL Java_art_Test928_doJNITableTest(
JNIEnv* env, jclass klass) { // Get the current table, as the delegate.
jvmtiError getorig_result = jvmti_env->GetJNIFunctionTable(&gOriginalEnv); if (JvmtiErrorToException(env, jvmti_env, getorig_result)) { return;
}
// Get the current table, as the override we'll install.
JNINativeInterface* env_override;
jvmtiError getoverride_result = jvmti_env->GetJNIFunctionTable(&env_override); if (JvmtiErrorToException(env, jvmti_env, getoverride_result)) { return;
}
// Install the override.
jvmtiError setoverride_result = jvmti_env->SetJNIFunctionTable(env_override); if (JvmtiErrorToException(env, jvmti_env, setoverride_result)) { return;
}
jobject global = env->NewGlobalRef(klass);
CHECK_EQ(1u, gGlobalRefCount);
env->DeleteGlobalRef(global);
// Try and create and destroy a thread.
env->CallStaticVoidMethod(klass, env->GetStaticMethodID(klass, "runThreadTest", "()V")); // Make sure something got ref'd, in the other thread we make and then clear a global ref so that // should at least be present.
CHECK_LT(1u, gGlobalRefCount);
// Install the "original." There is no real reset.
size_t final_global_ref_count = gGlobalRefCount;
jvmtiError setoverride2_result = jvmti_env->SetJNIFunctionTable(gOriginalEnv); if (JvmtiErrorToException(env, jvmti_env, setoverride2_result)) { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.