diff options
| author | 2017-04-20 13:35:05 -0700 | |
|---|---|---|
| committer | 2017-04-20 22:47:20 +0000 | |
| commit | 0af8cde95a267c86c3e3982f88cab1c7ffb62625 (patch) | |
| tree | 5d4c722652a375f088b802d1ef321a54e026ecc5 /runtime/openjdkjvmti/ti_method.cc | |
| parent | 65af20b1aaa2b23abaae3e4a21d7b6cdcb156889 (diff) | |
Do native method bind in jvmti-stress
Extend the jvmti-stress test suite to intercept the NativeMethodBind
event for every method.
Also fix small issue where we tried to add a local reference to a null
thread in ti_method.cc if we had an event trigger before VMInit.
Test: ./test/testrunner/testrunner.py --host --jvmti-stress -j40
Bug: 37432636
Change-Id: I2d83fc460b18edf035ed7296b8e2b06cff3671e5
Diffstat (limited to 'runtime/openjdkjvmti/ti_method.cc')
| -rw-r--r-- | runtime/openjdkjvmti/ti_method.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/openjdkjvmti/ti_method.cc b/runtime/openjdkjvmti/ti_method.cc index 2adabbaff4..f7e53474aa 100644 --- a/runtime/openjdkjvmti/ti_method.cc +++ b/runtime/openjdkjvmti/ti_method.cc @@ -44,6 +44,7 @@ #include "ScopedLocalRef.h" #include "thread-inl.h" #include "thread_list.h" +#include "ti_phase.h" namespace openjdkjvmti { @@ -54,12 +55,14 @@ struct TiMethodCallback : public art::MethodCallback { OVERRIDE REQUIRES_SHARED(art::Locks::mutator_lock_) { if (event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kNativeMethodBind)) { art::Thread* thread = art::Thread::Current(); + art::JNIEnvExt* jnienv = thread->GetJniEnv(); ScopedLocalRef<jthread> thread_jni( - thread->GetJniEnv(), thread->GetJniEnv()->AddLocalReference<jthread>(thread->GetPeer())); + jnienv, PhaseUtil::IsLivePhase() ? jnienv->AddLocalReference<jthread>(thread->GetPeer()) + : nullptr); art::ScopedThreadSuspension sts(thread, art::ThreadState::kNative); event_handler->DispatchEvent<ArtJvmtiEvent::kNativeMethodBind>( thread, - static_cast<JNIEnv*>(thread->GetJniEnv()), + static_cast<JNIEnv*>(jnienv), thread_jni.get(), art::jni::EncodeArtMethod(method), const_cast<void*>(cur_method), |