From 0af8cde95a267c86c3e3982f88cab1c7ffb62625 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Thu, 20 Apr 2017 13:35:05 -0700 Subject: 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 --- runtime/openjdkjvmti/ti_method.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'runtime/openjdkjvmti/ti_method.cc') 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 thread_jni( - thread->GetJniEnv(), thread->GetJniEnv()->AddLocalReference(thread->GetPeer())); + jnienv, PhaseUtil::IsLivePhase() ? jnienv->AddLocalReference(thread->GetPeer()) + : nullptr); art::ScopedThreadSuspension sts(thread, art::ThreadState::kNative); event_handler->DispatchEvent( thread, - static_cast(thread->GetJniEnv()), + static_cast(jnienv), thread_jni.get(), art::jni::EncodeArtMethod(method), const_cast(cur_method), -- cgit v1.2.3-59-g8ed1b