LOG("- Removing Java<->XPCOM binding (Java=0x%08x | XPCOM=0x%08x) weakref=0x%08x\n", hash, (int) xpcomObjKey, (PRUint32) jweakref);
LOG(("- Removing Java<->XPCOM binding (Java=0x%08x | XPCOM=0x%08x) weakref=0x%08x\n", hash, (int) xpcomObjKey, (PRUint32) jweakref));
RemoveJavaXPCOMBinding(JNIEnv* env, jobject aJavaObject, void* aXPCOMObject){  // We either get a Java or an XPCOM object.  So find the other object.  jint hash = 0;  JavaXPCOMBindingEntry* entry = nsnull;  if (aJavaObject) {    hash = env->CallIntMethod(aJavaObject, hashCodeMID);    JavaXPCOMBindingEntry* e =      NS_STATIC_CAST(JavaXPCOMBindingEntry*,                     PL_DHashTableOperate(gJAVAtoXPCOMBindings,                                          NS_INT32_TO_PTR(hash),                                          PL_DHASH_LOOKUP));    if (PL_DHASH_ENTRY_IS_BUSY(e))      entry = e;  } else {    JavaXPCOMBindingEntry* e =      NS_STATIC_CAST(JavaXPCOMBindingEntry*,                     PL_DHashTableOperate(gXPCOMtoJAVABindings, aXPCOMObject,                                          PL_DHASH_LOOKUP));    if (PL_DHASH_ENTRY_IS_BUSY(e))      entry = e;  }  NS_ASSERTION(entry != nsnull, "Failed to find matching entry");  if (entry) {    jobject jweakref = entry->mJavaObject;    void* xpcom_obj = entry->mXPCOMInstance;    // Get keys.  For Java, we use the hash key of the Java object.  For XPCOM,    // we get the 'actual' object (either the nsJavaXPTCStub or the instance    // that is wrapped by JavaXPCOMInstance).    void* xpcomObjKey = nsnull;    if (hash == 0)      hash = env->CallIntMethod(jweakref, hashCodeMID);    if (aXPCOMObject) {      xpcomObjKey = aXPCOMObject;    } else {      if (IsXPTCStub(xpcom_obj))        xpcomObjKey = GetXPTCStubAddr(xpcom_obj);      else        xpcomObjKey = ((JavaXPCOMInstance*) xpcom_obj)->GetInstance();    }    NS_ASSERTION(env->IsSameObject(jweakref, aJavaObject),                 "Weakref does not point to expected Java object");    NS_ASSERTION(!env->IsSameObject(jweakref, NULL),                 "Weakref refers to garbage collected Java object. No longer valid");    // Remove both instances from stores    PL_DHashTableOperate(gJAVAtoXPCOMBindings, NS_INT32_TO_PTR(hash),                         PL_DHASH_REMOVE);    PL_DHashTableOperate(gXPCOMtoJAVABindings, xpcomObjKey, PL_DHASH_REMOVE);    LOG("- Removing Java<->XPCOM binding (Java=0x%08x | XPCOM=0x%08x) weakref=0x%08x\n",        hash, (int) xpcomObjKey, (PRUint32) jweakref);    env->DeleteWeakGlobalRef(NS_STATIC_CAST(jweak, jweakref));  }}