else
if (aResult.l == nsnull) { rv = NS_ERROR_OUT_OF_MEMORY; break; } } else {
SetRetval(JNIEnv *env, const nsXPTParamInfo &aParamInfo,          const nsXPTMethodInfo* aMethodInfo, nsIInterfaceInfo* aIInfo,          PRUint16 aMethodIndex, nsXPTCVariant* aDispatchParams,          nsXPTCVariant &aVariant, jvalue &aResult){  nsresult rv = NS_OK;  const nsXPTType &type = aParamInfo.GetType();  switch (type.TagPart())  {    case nsXPTType::T_I8:    case nsXPTType::T_U8:      aResult.b = aVariant.val.u8;      break;    case nsXPTType::T_I16:    case nsXPTType::T_U16:      aResult.s = aVariant.val.u16;      break;    case nsXPTType::T_I32:    case nsXPTType::T_U32:      aResult.i = aVariant.val.u32;      break;    case nsXPTType::T_I64:    case nsXPTType::T_U64:      aResult.j = aVariant.val.u64;      break;    case nsXPTType::T_FLOAT:      aResult.f = aVariant.val.f;      break;    case nsXPTType::T_DOUBLE:      aResult.d = aVariant.val.d;      break;    case nsXPTType::T_BOOL:      aResult.z = aVariant.val.b;      break;    case nsXPTType::T_CHAR:      aResult.c = aVariant.val.c;      break;    case nsXPTType::T_WCHAR:      aResult.c = aVariant.val.wc;      break;    case nsXPTType::T_CHAR_STR:    {      if (aVariant.ptr)        aResult.l = env->NewStringUTF((const char*) aVariant.ptr);      else        aResult.l = nsnull;    }    break;    case nsXPTType::T_WCHAR_STR:    {      if (aVariant.ptr) {        PRUint32 length = nsCRT::strlen((const PRUnichar*) aVariant.ptr);        aResult.l = env->NewString((const jchar*) aVariant.ptr, length);      } else {        aResult.l = nsnull;      }    }    break;    case nsXPTType::T_IID:    {      if (aVariant.ptr) {        nsID* iid = (nsID*) aVariant.ptr;        char* iid_str = iid->ToString();        aResult.l = env->NewStringUTF(iid_str);        PR_Free(iid_str);      } else {        aResult.l = nsnull;      }    }    break;    case nsXPTType::T_INTERFACE:    case nsXPTType::T_INTERFACE_IS:    {      if (aVariant.val.p) {        jobject java_obj = GetMatchingJavaObject(env, aVariant.val.p);        if (java_obj == nsnull) {          nsID iid;          JavaXPCOMInstance* inst;          rv = GetIIDForMethodParam(aIInfo, aMethodInfo, aParamInfo,                                    aMethodIndex, aDispatchParams, PR_TRUE, iid);          if (NS_FAILED(rv))            return rv;          nsISupports* variant =                              NS_REINTERPRET_CAST(nsISupports*, aVariant.val.p);          inst = CreateJavaXPCOMInstance(variant, &iid);          NS_RELEASE(variant);   // JavaXPCOMInstance has owning ref          if (inst) {            // create java stub            char* iface_name;            inst->InterfaceInfo()->GetName(&iface_name);            java_obj = CreateJavaWrapper(env, iface_name);            if (java_obj)              AddJavaXPCOMBinding(env, java_obj, inst);          }        }        // XXX not sure if this is necessary        // If returned object is an nsJavaXPTCStub, release it.        nsISupports* xpcom_obj = NS_STATIC_CAST(nsISupports*, aVariant.val.p);        nsJavaXPTCStub* stub = nsnull;        xpcom_obj->QueryInterface(NS_GET_IID(nsJavaXPTCStub), (void**) &stub);        if (stub) {          NS_RELEASE(xpcom_obj);          NS_RELEASE(stub);        }        aResult.l = java_obj;      } else {        aResult.l = nsnull;      }    }    break;    case nsXPTType::T_ASTRING:    case nsXPTType::T_DOMSTRING:    {      if (aVariant.ptr) {        nsString* str = (nsString*) aVariant.ptr;        aResult.l = env->NewString(str->get(), str->Length());      } else {        aResult.l = nsnull;      }    }    break;    case nsXPTType::T_UTF8STRING:    case nsXPTType::T_CSTRING:    {      if (aVariant.ptr) {        nsCString* str = (nsCString*) aVariant.ptr;        aResult.l = env->NewStringUTF(str->get());      } else {        aResult.l = nsnull;      }    }    break;    case nsXPTType::T_VOID:      // handle "void *" as an "int" in Java      LOG((" returns int (void*)"));      aResult.i = (jint) aVariant.val.p;      break;    case nsXPTType::T_ARRAY:      NS_WARNING("array types are not yet supported");      return NS_ERROR_NOT_IMPLEMENTED;    default:      NS_WARNING("unexpected parameter type");      return NS_ERROR_UNEXPECTED;  }  return rv;}