From 791cb363b77332e3abdf4039102dfcdb863ce6c3 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Mon, 2 May 2016 05:19:07 -0700 Subject: Use macro annotation to load native library This also removes the need for third projects to depend on a "loader library". --- plugin/src/sbt-test/sbt-jni/simple/native/src/library.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 plugin/src/sbt-test/sbt-jni/simple/native/src/library.c (limited to 'plugin/src/sbt-test/sbt-jni/simple/native/src/library.c') diff --git a/plugin/src/sbt-test/sbt-jni/simple/native/src/library.c b/plugin/src/sbt-test/sbt-jni/simple/native/src/library.c new file mode 100644 index 0000000..4fa15b1 --- /dev/null +++ b/plugin/src/sbt-test/sbt-jni/simple/native/src/library.c @@ -0,0 +1,16 @@ +#include +#include "simple_Library__.h" + +/* + * Class: simple_Library__ + * Method: say + * Signature: (Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_simple_Library_00024_say +(JNIEnv *env, jobject clazz, jstring message) { + const char* msg = (*env)->GetStringUTFChars(env, message, 0); + fprintf(stdout, "Printing from native library: %s\n", msg); + fflush(stdout); + (*env)->ReleaseStringUTFChars(env, message, msg); + return 42; +} -- cgit v1.2.3