diff --git a/rclmodoki/build.gradle b/rclmodoki/build.gradle index 7005334..af485fc 100644 --- a/rclmodoki/build.gradle +++ b/rclmodoki/build.gradle @@ -65,7 +65,7 @@ afterEvaluate { from components.release groupId = 'jp.eyrin' artifactId = 'rclmodoki' - version = '0.0.1' + version = '0.0.2' } } } diff --git a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp index d93eb33..a58ce00 100644 --- a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp +++ b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp @@ -65,16 +65,7 @@ jint subscription_get_publisher_count(JNIEnv *env, jobject thiz, jlong subscript return subscription->get_publisher_count(); } -} // namespace rclmodoki - -extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { - using namespace rclmodoki; - - JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { - return JNI_ERR; - } - +void rclmodoki_init(JNIEnv *env) { // Init MessageTypes for (auto &message_type : message_types) { message_type.second.jni_class = new JNIClass(env, env->FindClass(message_type.first.c_str())); @@ -111,6 +102,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { }; env->RegisterNatives(subscription_class, subscription_methods, sizeof(subscription_methods) / sizeof(JNINativeMethod)); - - return JNI_VERSION_1_6; } + +} // namespace rclmodoki diff --git a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp index 8549247..cb775f8 100644 --- a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp +++ b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp @@ -29,6 +29,8 @@ using MessageTypes = std::unordered_map; extern MessageTypes message_types; +void rclmodoki_init(JNIEnv *env); + inline std::string from_jstring(JNIEnv *env, jstring s) { const char *s_ = env->GetStringUTFChars(s, nullptr); std::string res{s_};