diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-01-24 01:11:54 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-01-24 01:11:54 +0000 |
commit | d8e98ed2c80e0b39d50c179e34431faeca38daca (patch) | |
tree | d4ff85b45a718f46395cbdacf265e8c8d084aef4 | |
parent | 663568b9880e297ebcc8d4026600734034046e27 (diff) | |
parent | 9adf8bd2d0119056194f373484bb8e5545b8ba0c (diff) | |
download | dexmaker-d8e98ed2c80e0b39d50c179e34431faeca38daca.tar.gz |
Merge "Restrict InspectClass to current thread."
3 files changed, 9 insertions, 6 deletions
diff --git a/README.version b/README.version index 1f9ffd3..a4a21f2 100644 --- a/README.version +++ b/README.version @@ -12,4 +12,5 @@ Local Modifications: Add ability to run dexmaker tests from within the source tree (I1b146841099b54f64d4a7dfe743b88717793619a) Allow to share classloader via dexmaker.share_classloader system property (I324cddd644610eef811c620a1fccf6a24b2b9406) Do not read Build.VERSION to allow non-standard Android distributions (Ia8c4ba4c82cd6f193c565f1bfe48faffc4aac08f) - Temporarily ignore failing test (Ibf7b6c2eb05c5ff83f0817f9224369e20c0b775d) + Temporarily ignore failing test (Ibf7b6c2eb05c5ff83f0817f9224369e20c0b775d) + Restrict InspectClass to current thread. (Ic62951ff81bed60ac7512455fad65210e4b728a9, need upstreaming) diff --git a/dexmaker-mockito-inline-extended/src/main/java/com/android/dx/mockito/inline/StaticMockMethodAdvice.java b/dexmaker-mockito-inline-extended/src/main/java/com/android/dx/mockito/inline/StaticMockMethodAdvice.java index 18c1bcc..7a6f273 100644 --- a/dexmaker-mockito-inline-extended/src/main/java/com/android/dx/mockito/inline/StaticMockMethodAdvice.java +++ b/dexmaker-mockito-inline-extended/src/main/java/com/android/dx/mockito/inline/StaticMockMethodAdvice.java @@ -152,7 +152,7 @@ class StaticMockMethodAdvice { return subclasses; } - private synchronized static native String nativeGetCalledClassName(); + private synchronized static native String nativeGetCalledClassName(Thread currentThread); private Class<?> getClassMethodWasCalledOn(MethodDesc methodDesc) throws ClassNotFoundException, NoSuchMethodException { @@ -183,7 +183,7 @@ class StaticMockMethodAdvice { return null; } - String calledClassName = nativeGetCalledClassName(); + String calledClassName = nativeGetCalledClassName(Thread.currentThread()); return Class.forName(calledClassName); } } diff --git a/dexmaker-mockito-inline-extended/src/main/jni/staticjvmtiagent/agent.cc b/dexmaker-mockito-inline-extended/src/main/jni/staticjvmtiagent/agent.cc index 3956893..5fcc4b1 100644 --- a/dexmaker-mockito-inline-extended/src/main/jni/staticjvmtiagent/agent.cc +++ b/dexmaker-mockito-inline-extended/src/main/jni/staticjvmtiagent/agent.cc @@ -747,7 +747,9 @@ namespace com_android_dx_mockito_inline { extern "C" JNIEXPORT jstring JNICALL Java_com_android_dx_mockito_inline_StaticMockMethodAdvice_nativeGetCalledClassName(JNIEnv* env, - jclass klass) { + jclass klass, + jthread currentThread) { + JavaVM *vm; jint jvmError = env->GetJavaVM(&vm); if (jvmError != JNI_OK) { @@ -804,7 +806,7 @@ namespace com_android_dx_mockito_inline { GOTO_ON_ERROR(unregister_env_and_exit); error = jvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - nullptr); + currentThread); GOTO_ON_ERROR(unset_cb_and_exit); frameToInspect = &frameInfo[callingFrameNum]; @@ -813,7 +815,7 @@ namespace com_android_dx_mockito_inline { disable_hook_and_exit: jvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - nullptr); + currentThread); unset_cb_and_exit: memset(&cb, 0, sizeof(cb)); |