Index: jni/JniFilterChangeCallback.cpp |
diff --git a/jni/JniFilterChangeCallback.cpp b/jni/JniFilterChangeCallback.cpp |
index a1b19011470495265b67a71fd75ff8ccf4d5e38f..00c4b945f4976c2d3c89e1d5167145a8615517b9 100644 |
--- a/jni/JniFilterChangeCallback.cpp |
+++ b/jni/JniFilterChangeCallback.cpp |
@@ -31,23 +31,29 @@ static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) |
delete JniLongToTypePtr<JniFilterChangeCallback>(ptr); |
} |
-JniFilterChangeCallback::JniFilterChangeCallback(JNIEnv* env, jobject callbackObject) |
- : JniCallbackBase(env, callbackObject), jsValueClass(new JniGlobalReference<jclass>(env, env->FindClass(PKG("JsValue")))) |
+JniFilterChangeCallback::JniFilterChangeCallback(JNIEnv* env, |
+ jobject callbackObject) |
+ : JniCallbackBase(env, callbackObject), jsValueClass( |
+ new JniGlobalReference<jclass>(env, env->FindClass(PKG("JsValue")))) |
{ |
} |
-void JniFilterChangeCallback::Callback(const std::string& arg, const AdblockPlus::JsValuePtr jsValue) |
+void JniFilterChangeCallback::Callback(const std::string& arg, |
+ const AdblockPlus::JsValuePtr jsValue) |
{ |
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); |