From 6f9db492bddab99ebb3ccea02eaa881746c3e6d7 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 31 Jul 2013 17:47:22 +0000 Subject: [PATCH] Merge "Fix Class.getDex." --- vm/Init.cpp | 14 ++++++++++++++ vm/native/java_lang_Class.cpp | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/vm/Init.cpp b/vm/Init.cpp index d5b498941..9c4ee480f 100644 --- a/vm/Init.cpp +++ b/vm/Init.cpp @@ -1627,6 +1627,20 @@ static bool registerSystemNatives(JNIEnv* pEnv) // First set up JniConstants, which is used by libcore. JniConstants::init(pEnv); + // Set up our single JNI method. + // TODO: factor this out if we add more. + jclass c = pEnv->FindClass("java/lang/Class"); + if (c == NULL) { + dvmAbort(); + } + JNIEXPORT jobject JNICALL Java_java_lang_Class_getDex(JNIEnv* env, jclass javaClass); + const JNINativeMethod Java_java_lang_Class[] = { + { "getDex", "()Lcom/android/dex/Dex;", (void*) Java_java_lang_Class_getDex }, + }; + if (pEnv->RegisterNatives(c, Java_java_lang_Class, 1) != JNI_OK) { + dvmAbort(); + } + // Most JNI libraries can just use System.loadLibrary, but you can't // if you're the library that implements System.loadLibrary! loadJniLibrary("javacore"); diff --git a/vm/native/java_lang_Class.cpp b/vm/native/java_lang_Class.cpp index 88d31eff8..e68be7bf0 100644 --- a/vm/native/java_lang_Class.cpp +++ b/vm/native/java_lang_Class.cpp @@ -785,7 +785,7 @@ JNIEXPORT jobject JNICALL Java_java_lang_Class_getDex(JNIEnv* env, jclass javaCl jmethodID com_android_dex_Dex_create = env->GetStaticMethodID(com_android_dex_Dex, - "", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); + "create", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); if (com_android_dex_Dex_create == NULL) { return NULL; } -- 2.11.0