JS_AddRoot(cx, &member_descriptor->invoke_func_obj);
JS_AddNamedRoot(cx, &member_descriptor->invoke_func_obj, "&member_descriptor->invoke_func_obj");
add_java_method_to_class_descriptor(JSContext *cx, JNIEnv *jEnv,                                    JavaClassDescriptor *class_descriptor,                                     jstring method_name_jstr,                                    jobject java_method,                                    JSBool is_static_method,                                    JSBool is_constructor){    jmethodID methodID;    JSFunction *fun;    jclass java_class = class_descriptor->java_class;    JavaMemberDescriptor *member_descriptor = NULL;    const char *sig_cstr = NULL;    const char *method_name = NULL;    JavaMethodSignature *signature = NULL;    JavaMethodSpec **specp, *method_spec = NULL;                if (is_constructor) {        member_descriptor = jsj_GetJavaClassConstructors(cx, class_descriptor);    } else {        if (is_static_method) {            member_descriptor = jsj_GetJavaStaticMemberDescriptor(cx, jEnv, class_descriptor, method_name_jstr);        } else {            member_descriptor = jsj_GetJavaMemberDescriptor(cx, jEnv, class_descriptor, method_name_jstr);	}        fun = JS_NewFunction(cx, jsj_JavaInstanceMethodWrapper, 0,	                     JSFUN_BOUND_METHOD, NULL, member_descriptor->name);	member_descriptor->invoke_func_obj = JS_GetFunctionObject(fun);	JS_AddRoot(cx, &member_descriptor->invoke_func_obj);    }    if (!member_descriptor)        return JS_FALSE;        method_spec = (JavaMethodSpec*)JS_malloc(cx, sizeof(JavaMethodSpec));    if (!method_spec)        goto error;    memset(method_spec, 0, sizeof(JavaMethodSpec));    signature = jsj_InitJavaMethodSignature(cx, jEnv, java_method, &method_spec->signature);    if (!signature)        goto error;    method_name = JS_strdup(cx, member_descriptor->name);    if (!method_name)        goto error;    method_spec->name = method_name;        sig_cstr = jsj_ConvertJavaMethodSignatureToString(cx, signature);    if (!sig_cstr)        goto error;    if (is_static_method)        methodID = (*jEnv)->GetStaticMethodID(jEnv, java_class, method_name, sig_cstr);    else        methodID = (*jEnv)->GetMethodID(jEnv, java_class, method_name, sig_cstr);    method_spec->methodID = methodID;        if (!methodID) {        jsj_UnexpectedJavaError(cx, jEnv,                                "Can't get Java method ID for %s.%s() (sig=%s)",                                class_descriptor->name, method_name, sig_cstr);        goto error;    }        JS_free(cx, (char*)sig_cstr);    /* Add method to end of list of overloaded methods for this class member */     specp = &member_descriptor->methods;    while (*specp) {        specp = &(*specp)->next;    }    *specp = method_spec;    return JS_TRUE;error:    if (method_spec)        JS_FREE_IF(cx, (char*)method_spec->name);    JS_FREE_IF(cx, (char*)sig_cstr);    if (signature)        jsj_PurgeJavaMethodSignature(cx, jEnv, signature);    JS_FREE_IF(cx, method_spec);    return JS_FALSE;}