ART: Add GetThreadState
Add support for GetThreadState. Add test.
Bug: 31684593
Test: m test-art-host-run-test-924-threads
Change-Id: I67a240c711e1165cfb72a856fc59ca69abaec3f6
diff --git a/test/924-threads/threads.cc b/test/924-threads/threads.cc
index bcd813f..4abf8fc 100644
--- a/test/924-threads/threads.cc
+++ b/test/924-threads/threads.cc
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#include "threads.h"
-
#include <stdio.h>
#include "android-base/stringprintf.h"
@@ -92,16 +90,14 @@
return ret;
}
-// Don't do anything
-jint OnLoad(JavaVM* vm,
- char* options ATTRIBUTE_UNUSED,
- void* reserved ATTRIBUTE_UNUSED) {
- if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0)) {
- printf("Unable to get jvmti env!\n");
- return 1;
+extern "C" JNIEXPORT jint JNICALL Java_Main_getThreadState(
+ JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jthread thread) {
+ jint state;
+ jvmtiError result = jvmti_env->GetThreadState(thread, &state);
+ if (JvmtiErrorToException(env, result)) {
+ return 0;
}
- SetAllCapabilities(jvmti_env);
- return 0;
+ return state;
}
} // namespace Test924Threads