summaryrefslogtreecommitdiff
path: root/test/986-native-method-bind/native_bind.cc
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-04-20 09:15:08 -0700
committer Alex Light <allight@google.com> 2017-04-20 22:47:01 +0000
commit65af20b1aaa2b23abaae3e4a21d7b6cdcb156889 (patch)
tree8bf0c219ec23392afe2f04972b6abc2665c9ab80 /test/986-native-method-bind/native_bind.cc
parentaa03f6fa38da0166790f2b22b679e6568ad56f7d (diff)
Agent libraries need to be searched for JNI functions
This makes agent libraries the option of last resort for native method implementations. This will allow one to not need to manually link all native methods in an agent library. Bug: 37522517 Bug: 37432636 Test: ./test.py --host -j40 Change-Id: I5ad78a15e7e2799d2a877c5d603342899e2a1bd1
Diffstat (limited to 'test/986-native-method-bind/native_bind.cc')
-rw-r--r--test/986-native-method-bind/native_bind.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/986-native-method-bind/native_bind.cc b/test/986-native-method-bind/native_bind.cc
index 4f93f87dfe..eec635b2a0 100644
--- a/test/986-native-method-bind/native_bind.cc
+++ b/test/986-native-method-bind/native_bind.cc
@@ -38,11 +38,16 @@ static void doUpPrintCall(JNIEnv* env, const char* function) {
env->CallStaticVoidMethod(klass.get(), targetMethod);
}
-extern "C" JNIEXPORT void JNICALL Java_art_Test986_00024Transform_sayHi(
+extern "C" JNIEXPORT void JNICALL Java_art_Test986_00024Transform_sayHi__(
JNIEnv* env, jclass klass ATTRIBUTE_UNUSED) {
doUpPrintCall(env, "doSayHi");
}
+extern "C" JNIEXPORT void JNICALL Java_art_Test986_00024Transform_sayHi2(
+ JNIEnv* env, jclass klass ATTRIBUTE_UNUSED) {
+ doUpPrintCall(env, "doSayHi2");
+}
+
extern "C" JNIEXPORT void JNICALL NoReallySayGoodbye(JNIEnv* env, jclass klass ATTRIBUTE_UNUSED) {
doUpPrintCall(env, "doSayBye");
}
@@ -106,5 +111,17 @@ extern "C" JNIEXPORT void JNICALL Java_art_Test986_setNativeBindNotify(
}
}
+extern "C" JNIEXPORT void JNICALL Java_art_Test986_rebindTransformClass(
+ JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jclass k) {
+ JNINativeMethod m[2];
+ m[0].name= "sayHi";
+ m[0].signature = "()V";
+ m[0].fnPtr = reinterpret_cast<void*>(Java_art_Test986_00024Transform_sayHi__);
+ m[1].name= "sayHi2";
+ m[1].signature = "()V";
+ m[1].fnPtr = reinterpret_cast<void*>(Java_art_Test986_00024Transform_sayHi2);
+ env->RegisterNatives(k, m, 2);
+}
+
} // namespace Test986NativeBind
} // namespace art