Change test 136 to use dlopen
dlopen self to prevent the native libary being closed from
DestroyJavaVM. We need this since it is the library currently
executing code.
Bug: 28406866
Change-Id: I8fab78bc7c27f5c03a6670d20d5cf8e44295d5e2
diff --git a/test/136-daemon-jni-shutdown/daemon_jni_shutdown.cc b/test/136-daemon-jni-shutdown/daemon_jni_shutdown.cc
index 54879fb..074c9b1 100644
--- a/test/136-daemon-jni-shutdown/daemon_jni_shutdown.cc
+++ b/test/136-daemon-jni-shutdown/daemon_jni_shutdown.cc
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <dlfcn.h>
#include <iostream>
#include "base/casts.h"
@@ -45,6 +46,9 @@
self->SetTopOfShadowStack(nullptr);
JavaVM* vm = down_cast<JNIEnvExt*>(env)->vm;
vm->DetachCurrentThread();
+ // Open ourself again to make sure the native library does not get unloaded from
+ // underneath us due to DestroyJavaVM. b/28406866
+ dlopen(kIsDebugBuild ? "libarttestd.so" : "libarttest.so", RTLD_NOW);
vm->DestroyJavaVM();
vm_was_shutdown.store(true);
// Give threads some time to get stuck in ExceptionCheck.