summaryrefslogtreecommitdiffstats
path: root/java/jni/helper.cxx
diff options
context:
space:
mode:
authorJulien Decaen <[email protected]>2016-10-28 11:22:29 +0200
committerpetreeftime <[email protected]>2016-10-28 13:35:36 +0200
commit2c3706fc16bf22c28ea3051703e98fc27b73f365 (patch)
tree3a0c749b33ae6a1485449c60812f5702665743da /java/jni/helper.cxx
parentd9c777bc576b5365c2064d55fe872f272faa92e8 (diff)
Fix JNI FindClass "tinyb/BluetoothNotification" not found
- Issue #52 : JNI call to findClass BluetoothNotification failed - This issue happen with javafx application, but not with "simple" java application. - This issue happen only with "tinyb/BluetoothNotification" interface. - Using the callback reference to retrieve the class instead of using FindClass works fine. Signed-off-by: Julien Decaen <[email protected]>
Diffstat (limited to 'java/jni/helper.cxx')
-rw-r--r--java/jni/helper.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/java/jni/helper.cxx b/java/jni/helper.cxx
index 6952184f..3ff6ffb4 100644
--- a/java/jni/helper.cxx
+++ b/java/jni/helper.cxx
@@ -52,6 +52,17 @@ jclass search_class(JNIEnv *env, const char *clazz_name)
return clazz;
}
+jclass search_class(JNIEnv *env, jobject obj)
+{
+ jclass clazz = env->GetObjectClass(obj);
+ if (!clazz)
+ {
+ std::string error = "no class found: ";
+ throw std::runtime_error(error);
+ }
+ return clazz;
+}
+
jmethodID search_method(JNIEnv *env, jclass clazz, const char *method_name,
const char *prototype, bool is_static)
{