diff options
| -rw-r--r-- | src/jni_compiler_test.cc | 20 | ||||
| -rw-r--r-- | test/MyClassNatives/MyClassNatives.java | 1 |
2 files changed, 20 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 diff --git a/test/MyClassNatives/MyClassNatives.java b/test/MyClassNatives/MyClassNatives.java index d8df19b224..55ec0bdfe5 100644 --- a/test/MyClassNatives/MyClassNatives.java +++ b/test/MyClassNatives/MyClassNatives.java @@ -18,6 +18,7 @@ class MyClass { native void throwException(); native void foo(); native int bar(int count); + static native int sbar(int count); native int fooI(int x); native int fooII(int x, int y); native long fooJJ(long x, long y); |