JS_AddRoot(cx, &argv[arg_num]);
JS_AddNamedRoot(cx, &argv[arg_num], "&argv[arg_num]");
Java_netscape_javascript_JSObject_call(JNIEnv *jEnv, jobject java_wrapper_obj,                                       jstring function_name_jstr, jobjectArray java_args){    int i, argc, arg_num;    jsval *argv;    JSContext *cx = NULL;    JSObject *js_obj;    jsval js_val, function_val;    int dummy_cost;    JSBool dummy_bool;    const jchar *function_name_ucs2;    jsize function_name_len;    JSErrorReporter saved_reporter;    jboolean is_copy;    jobject result;    JSJavaThreadState *jsj_env;        jsj_env = jsj_enter_js(jEnv, NULL, java_wrapper_obj, &cx, &js_obj, &saved_reporter, NULL, 0, NULL);    if (!jsj_env)        return NULL;        function_name_ucs2 = NULL;    result = NULL;    if (!function_name_jstr) {        JS_ReportErrorNumber(cx, jsj_GetErrorMessage, NULL,                                                    JSJMSG_NULL_FUNCTION_NAME);        goto done;    }    /* Get the function name to eval as raw Unicode characters */    function_name_ucs2 = (*jEnv)->GetStringChars(jEnv, function_name_jstr, &is_copy);    if (!function_name_ucs2) {        JS_ASSERT(0);        goto done;    }    function_name_len = (*jEnv)->GetStringLength(jEnv, function_name_jstr);        /* Allocate space for JS arguments */    if (java_args) {        argc = (*jEnv)->GetArrayLength(jEnv, java_args);        argv = (jsval*)JS_malloc(cx, argc * sizeof(jsval));    } else {        argc = 0;        argv = 0;    }    /* Convert arguments from Java to JS values */    for (arg_num = 0; arg_num < argc; arg_num++) {        jobject arg = (*jEnv)->GetObjectArrayElement(jEnv, java_args, arg_num);        if (!jsj_ConvertJavaObjectToJSValue(cx, jEnv, arg, &argv[arg_num]))            goto cleanup_argv;        JS_AddRoot(cx, &argv[arg_num]);    }    if (!JS_GetUCProperty(cx, js_obj, function_name_ucs2, function_name_len,                          &function_val))        goto cleanup_argv;    if (!JS_CallFunctionValue(cx, js_obj, function_val, argc, argv, &js_val))        goto cleanup_argv;    jsj_ConvertJSValueToJavaObject(cx, jEnv, js_val, jsj_get_jlObject_descriptor(cx, jEnv),                                   &dummy_cost, &result, &dummy_bool);cleanup_argv:    if (argv) {        for (i = 0; i < arg_num; i++)            JS_RemoveRoot(cx, &argv[i]);        JS_free(cx, argv);    }done:    if (function_name_ucs2)        (*jEnv)->ReleaseStringChars(jEnv, function_name_jstr, function_name_ucs2);    if (!jsj_exit_js(cx, jsj_env, saved_reporter))        return NULL;        return result;}