Index: jni/JniUpdateAvailableCallback.cpp |
diff --git a/jni/JniUpdateAvailableCallback.cpp b/jni/JniUpdateAvailableCallback.cpp |
index d8a4b2181e7dc96917137787029bc67bd3eb692e..a7cacffdf6660e578e4d83ac8950882013fbe12b 100644 |
--- a/jni/JniUpdateAvailableCallback.cpp |
+++ b/jni/JniUpdateAvailableCallback.cpp |
@@ -41,14 +41,16 @@ void JniUpdateAvailableCallback::Callback(const std::string& arg) |
{ |
JNIEnvAcquire env(GetJavaVM()); |
- jclass clazz = env->GetObjectClass(GetCallbackObject()); |
- jmethodID method = env->GetMethodID(clazz, "updateAvailableCallback", |
- "(Ljava/lang/String;)V"); |
+ jmethodID method = env->GetMethodID( |
+ *JniLocalReference<jclass>(*env, |
+ env->GetObjectClass(GetCallbackObject())), |
+ "updateAvailableCallback", |
+ "(Ljava/lang/String;)V"); |
if (method) |
{ |
- jstring jArg = env->NewStringUTF(arg.c_str()); |
- env->CallVoidMethod(GetCallbackObject(), method, jArg); |
+ JniLocalReference<jstring> jArg(*env, env->NewStringUTF(arg.c_str())); |
+ env->CallVoidMethod(GetCallbackObject(), method, *jArg); |
} |
CheckAndLogJavaException(*env); |