summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2012-02-29 09:42:21 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2012-02-29 09:42:21 -0800
commit1415e20eeb100b49cc29e670dafb86a8bde7f92e (patch)
tree71d1d339753731621e7ce27061d10927c565fc8d
parentefbdefbf4f48990769fc98857a605dac62f3e29c (diff)
parent1cefdbdff559aff5a3ee5c0878ba3b505109e0f9 (diff)
Merge "Test invocation of static methods through JNI stub" into dalvik-dev
-rw-r--r--src/jni_compiler_test.cc20
-rw-r--r--test/MyClassNatives/MyClassNatives.java1
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);