diff options
Diffstat (limited to 'test/901-hello-ti-agent/basics.cc')
-rw-r--r-- | test/901-hello-ti-agent/basics.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/901-hello-ti-agent/basics.cc b/test/901-hello-ti-agent/basics.cc index 91662770be..cbd768663b 100644 --- a/test/901-hello-ti-agent/basics.cc +++ b/test/901-hello-ti-agent/basics.cc @@ -16,6 +16,8 @@ #include "901-hello-ti-agent/basics.h" +#include <thread> + #include <jni.h> #include <stdio.h> #include <string.h> @@ -159,5 +161,19 @@ extern "C" JNIEXPORT jboolean JNICALL Java_Main_checkLivePhase( return (current_phase == JVMTI_PHASE_LIVE) ? JNI_TRUE : JNI_FALSE; } +static void CallJvmtiFunction(jvmtiEnv* env, jclass klass, jvmtiError* err) { + jint n; + jmethodID* methods = nullptr; + *err = env->GetClassMethods(klass, &n, &methods); +} + +extern "C" JNIEXPORT jboolean JNICALL Java_Main_checkUnattached( + JNIEnv* env ATTRIBUTE_UNUSED, jclass Main_klass) { + jvmtiError res = JVMTI_ERROR_NONE; + std::thread t1(CallJvmtiFunction, jvmti_env, Main_klass, &res); + t1.join(); + return res == JVMTI_ERROR_UNATTACHED_THREAD; +} + } // namespace Test901HelloTi } // namespace art |