diff options
author | Brian Carlstrom <bdc@google.com> | 2013-06-19 15:08:24 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2013-06-20 16:53:02 -0700 |
commit | 0eba633357c6c01b298434c7fd8a5705b5b2e18f (patch) | |
tree | 88ff7d988b4e7691403c48caa5a72100c877d2ff /dalvikvm | |
parent | ad27f28fa7516b169ee9947ca24a04fd5600f2e6 (diff) | |
download | art-0eba633357c6c01b298434c7fd8a5705b5b2e18f.zip art-0eba633357c6c01b298434c7fd8a5705b5b2e18f.tar.gz art-0eba633357c6c01b298434c7fd8a5705b5b2e18f.tar.bz2 |
Use libnativehelper to find JNI_CreateJavaVM
Change-Id: If5da43aee75a3ac5337a90b25264ac30129e3933
Diffstat (limited to 'dalvikvm')
-rw-r--r-- | dalvikvm/dalvikvm.cc | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/dalvikvm/dalvikvm.cc b/dalvikvm/dalvikvm.cc index 1216e6b..dd68da0 100644 --- a/dalvikvm/dalvikvm.cc +++ b/dalvikvm/dalvikvm.cc @@ -14,7 +14,6 @@ * limitations under the License. */ -#include <dlfcn.h> #include <signal.h> #include <cstdio> @@ -22,6 +21,7 @@ #include <string> #include "jni.h" +#include "JniInvocation.h" #include "ScopedLocalRef.h" #include "toStringArray.h" #include "UniquePtr.h" @@ -125,7 +125,6 @@ static int dalvikvm(int argc, char** argv) { // [Do we need to catch & handle "-jar" here?] bool need_extra = false; const char* lib = "libdvm.so"; - const char* debug = NULL; const char* what = NULL; int curr_opt, arg_idx; for (curr_opt = arg_idx = 0; arg_idx < argc; arg_idx++) { @@ -167,23 +166,11 @@ static int dalvikvm(int argc, char** argv) { } // Find the JNI_CreateJavaVM implementation. - std::string library(lib); - if (debug != NULL) { - library += debug; - } - void* handle = dlopen(library.c_str(), RTLD_NOW); - if (handle == NULL) { - fprintf(stderr, "Failed to dlopen library %s: %s\n", library.c_str(), dlerror()); - return EXIT_FAILURE; - } - const char* symbol = "JNI_CreateJavaVM"; - void* sym = dlsym(handle, symbol); - if (handle == NULL) { - fprintf(stderr, "Failed to find symbol %s: %s\n", symbol, dlerror()); + JniInvocation jni_invocation; + if (!jni_invocation.Init(lib)) { + fprintf(stderr, "Failed to initialize JNI invocation API from %s\n", lib); return EXIT_FAILURE; } - typedef int (*Fn)(JavaVM** p_vm, JNIEnv** p_env, void* vm_args); - Fn JNI_CreateJavaVM = reinterpret_cast<Fn>(sym); JavaVMInitArgs init_args; init_args.version = JNI_VERSION_1_6; @@ -215,7 +202,6 @@ static int dalvikvm(int argc, char** argv) { rc = EXIT_FAILURE; } - dlclose(handle); return rc; } |