From 68d8b42ddec39ec0174162d90d4abaa004d1983e Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 17 Jul 2014 11:09:10 -0700 Subject: Wire up check JNI force copy mode. Increase check JNI checks. Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h. Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case of VM routines. Make class loader override and shared library class loader JNI global references rather than mirror pointers. Clean-ups to native bridge. Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55 --- runtime/native/java_lang_Runtime.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'runtime/native/java_lang_Runtime.cc') diff --git a/runtime/native/java_lang_Runtime.cc b/runtime/native/java_lang_Runtime.cc index fb708a24df..a85eec7464 100644 --- a/runtime/native/java_lang_Runtime.cc +++ b/runtime/native/java_lang_Runtime.cc @@ -43,7 +43,10 @@ static void Runtime_nativeExit(JNIEnv*, jclass, jint status) { exit(status); } -static jstring Runtime_nativeLoad(JNIEnv* env, jclass, jstring javaFilename, jobject javaLoader, jstring javaLdLibraryPath) { +static jstring Runtime_nativeLoad(JNIEnv* env, jclass, jstring javaFilename, jobject javaLoader, + jstring javaLdLibraryPath) { + // TODO: returns NULL on success or an error message describing the failure on failure. This + // should be refactored in terms of suppressed exceptions. ScopedUtfChars filename(env, javaFilename); if (filename.c_str() == NULL) { return NULL; @@ -64,14 +67,10 @@ static jstring Runtime_nativeLoad(JNIEnv* env, jclass, jstring javaFilename, job } } - std::string detail; + std::string error_msg; { - ScopedObjectAccess soa(env); - StackHandleScope<1> hs(soa.Self()); - Handle classLoader( - hs.NewHandle(soa.Decode(javaLoader))); JavaVMExt* vm = Runtime::Current()->GetJavaVM(); - bool success = vm->LoadNativeLibrary(filename.c_str(), classLoader, &detail); + bool success = vm->LoadNativeLibrary(env, filename.c_str(), javaLoader, &error_msg); if (success) { return nullptr; } @@ -79,7 +78,7 @@ static jstring Runtime_nativeLoad(JNIEnv* env, jclass, jstring javaFilename, job // Don't let a pending exception from JNI_OnLoad cause a CheckJNI issue with NewStringUTF. env->ExceptionClear(); - return env->NewStringUTF(detail.c_str()); + return env->NewStringUTF(error_msg.c_str()); } static jlong Runtime_maxMemory(JNIEnv*, jclass) { -- cgit v1.2.3-59-g8ed1b