if (!jargv) return JS_FALSE;
if (!jargv) { error_occurred = JS_TRUE; goto out; }
invoke_java_method(JSContext *cx, JSJavaThreadState *jsj_env,                   jobject java_class_or_instance,                   JavaClassDescriptor *class_descriptor,		   JavaMethodSpec *method,                   JSBool is_static_method,		   jsval *argv, jsval *vp){    jvalue java_value;    jvalue *jargv;    uintN argc, i;    jobject java_object;    jclass java_class;    jmethodID methodID;    JavaMethodSignature *signature;    JavaSignature *return_val_signature;    JSContext *old_cx;    JNIEnv *jEnv;    JSBool *localv;    methodID = method->methodID;    signature = &method->signature;    argc = signature->num_args;    jEnv = jsj_env->jEnv;    if (is_static_method) {        java_object = NULL;        java_class = java_class_or_instance;    } else {        java_object = java_class_or_instance;        java_class = NULL;    }    jargv = NULL;    if (argc) {        jargv = convert_JS_method_args_to_java_argv(cx, jEnv, argv, method, &localv);        if (!jargv)            return JS_FALSE;    }#define CALL_JAVA_METHOD(type, member)                                       \    PR_BEGIN_MACRO                                                           \    if (is_static_method) {                                                  \        java_value.member = (*jEnv)->CallStatic##type##MethodA(jEnv, java_class, methodID, jargv);\    } else {                                                                 \        java_value.member = (*jEnv)->Call##type##MethodA(jEnv, java_object, methodID, jargv);\    }                                                                        \    if ((*jEnv)->ExceptionOccurred(jEnv)) {                                  \        jsj_ReportJavaError(cx, jEnv, "Error calling method %s.%s()",        \                            class_descriptor->name, method->name);           \        goto error;                                                          \    }                                                                        \    PR_END_MACRO    old_cx = JSJ_SetDefaultJSContextForJavaThread(cx, jsj_env);    if (old_cx) {        JS_ReportError(cx, "Java thread in simultaneous use by more than "                           "one JSContext ?");    }    return_val_signature = signature->return_val_signature;    switch(return_val_signature->type) {    case JAVA_SIGNATURE_BYTE:        CALL_JAVA_METHOD(Byte, b);        break;    case JAVA_SIGNATURE_CHAR:        CALL_JAVA_METHOD(Char, c);        break;        case JAVA_SIGNATURE_FLOAT:        CALL_JAVA_METHOD(Float, f);        break;        case JAVA_SIGNATURE_DOUBLE:        CALL_JAVA_METHOD(Double, d);        break;        case JAVA_SIGNATURE_INT:        CALL_JAVA_METHOD(Int, i);        break;        case JAVA_SIGNATURE_LONG:        CALL_JAVA_METHOD(Long, j);        break;        case JAVA_SIGNATURE_SHORT:        CALL_JAVA_METHOD(Short, s);        break;        case JAVA_SIGNATURE_BOOLEAN:        CALL_JAVA_METHOD(Boolean, z);        break;        case JAVA_SIGNATURE_ARRAY:    case JAVA_SIGNATURE_CLASS:        CALL_JAVA_METHOD(Object, l);        break;        case JAVA_SIGNATURE_VOID:        if (is_static_method)            (*jEnv)->CallStaticVoidMethodA(jEnv, java_class, methodID, jargv);        else            (*jEnv)->CallVoidMethodA(jEnv, java_object, methodID, jargv);        if ((*jEnv)->ExceptionOccurred(jEnv)) {            jsj_ReportJavaError(cx, jEnv, "Error calling method %s.%s()",                                class_descriptor->name, method->name);            goto error;        }        break;            default:        PR_ASSERT(0);        return JS_FALSE;    }    for (i = 0; i < argc; i++) {        if (localv[i])            (*jEnv)->DeleteLocalRef(jEnv, jargv[i].l);    }    if (jargv)        JS_free(cx, jargv);    JSJ_SetDefaultJSContextForJavaThread(old_cx, jsj_env);    return jsj_ConvertJavaValueToJSValue(cx, jEnv, return_val_signature, &java_value, vp);error:    for (i = 0; i < argc; i++) {        if (localv[i])            (*jEnv)->DeleteLocalRef(jEnv, jargv[i].l);    }    if (jargv)       JS_free(cx, jargv);    JSJ_SetDefaultJSContextForJavaThread(old_cx, jsj_env);    return JS_FALSE;}