diff options
| author | 2012-02-29 09:42:21 -0800 | |
|---|---|---|
| committer | 2012-02-29 09:42:21 -0800 | |
| commit | 1415e20eeb100b49cc29e670dafb86a8bde7f92e (patch) | |
| tree | 71d1d339753731621e7ce27061d10927c565fc8d /src | |
| parent | efbdefbf4f48990769fc98857a605dac62f3e29c (diff) | |
| parent | 1cefdbdff559aff5a3ee5c0878ba3b505109e0f9 (diff) | |
Merge "Test invocation of static methods through JNI stub" into dalvik-dev
Diffstat (limited to 'src')
| -rw-r--r-- | src/jni_compiler_test.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/jni_compiler_test.cc b/src/jni_compiler_test.cc index cf7068570f..2166d37a21 100644 --- a/src/jni_compiler_test.cc +++ b/src/jni_compiler_test.cc @@ -36,6 +36,11 @@ JNIEXPORT jint JNICALL Java_MyClass_bar(JNIEnv* env, jobject thisObj, jint count return count + 1; } +extern "C" +JNIEXPORT jint JNICALL Java_MyClass_sbar(JNIEnv* env, jclass myClass, jint count) { + return count + 1; +} + namespace art { class JniCompilerTest : public CommonTest { @@ -128,7 +133,7 @@ TEST_F(JniCompilerTest, CompileAndRunNoArgMethod) { TEST_F(JniCompilerTest, CompileAndRunIntMethodThroughStub) { SirtRef<ClassLoader> class_loader(LoadDex("MyClassNatives")); SetupForTest(class_loader.get(), false, "bar", "(I)I", - NULL /* calling through stub will load &Java_MyClass_bar */); + NULL /* calling through stub will link with &Java_MyClass_bar */); std::string reason; ASSERT_TRUE(Runtime::Current()->GetJavaVM()->LoadNativeLibrary("", class_loader.get(), reason)) @@ -138,6 +143,19 @@ TEST_F(JniCompilerTest, CompileAndRunIntMethodThroughStub) { EXPECT_EQ(25, result); } +TEST_F(JniCompilerTest, CompileAndRunStaticIntMethodThroughStub) { + SirtRef<ClassLoader> class_loader(LoadDex("MyClassNatives")); + SetupForTest(class_loader.get(), true, "sbar", "(I)I", + NULL /* calling through stub will link with &Java_MyClass_sbar */); + + std::string reason; + ASSERT_TRUE(Runtime::Current()->GetJavaVM()->LoadNativeLibrary("", class_loader.get(), reason)) + << reason; + + jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 42); + EXPECT_EQ(43, result); +} + int gJava_MyClass_fooI_calls = 0; jint Java_MyClass_fooI(JNIEnv* env, jobject thisObj, jint x) { // 2 = SirtRef<ClassLoader> + thisObj |