Index: jni/JniFilterChangeCallback.cpp |
diff --git a/jni/JniFilterChangeCallback.cpp b/jni/JniFilterChangeCallback.cpp |
index a1b19011470495265b67a71fd75ff8ccf4d5e38f..3fe26c87cf03d00350912d51e85d316a021dca01 100644 |
--- a/jni/JniFilterChangeCallback.cpp |
+++ b/jni/JniFilterChangeCallback.cpp |
@@ -40,14 +40,15 @@ void JniFilterChangeCallback::Callback(const std::string& arg, const AdblockPlus |
{ |
JNIEnvAcquire env(GetJavaVM()); |
- jclass clazz = env->GetObjectClass(GetCallbackObject()); |
- jmethodID method = env->GetMethodID(clazz, "filterChangeCallback", "(Ljava/lang/String;" TYP("JsValue") ")V"); |
+ jmethodID method = env->GetMethodID( |
+ *JniLocalReference<jclass>(*env, env->GetObjectClass(GetCallbackObject())), |
+ "filterChangeCallback", "(Ljava/lang/String;" TYP("JsValue") ")V"); |
if (method) |
{ |
- jstring jArg = env->NewStringUTF(arg.c_str()); |
- jobject jJsValue = NewJniJsValue(*env, jsValue, jsValueClass->Get()); |
- env->CallVoidMethod(GetCallbackObject(), method, jArg, jJsValue); |
+ JniLocalReference<jstring> jArg(*env, env->NewStringUTF(arg.c_str())); |
+ JniLocalReference<jobject> jJsValue(*env, NewJniJsValue(*env, jsValue, jsValueClass->Get())); |
+ env->CallVoidMethod(GetCallbackObject(), method, *jArg, *jJsValue); |
} |
CheckAndLogJavaException(*env); |