Store a global weak ref to the Java object rather than the 'address' returned by the JVM

This commit is contained in:
pedemont@us.ibm.com
2004-09-30 23:34:47 +00:00
parent 4639ccfd86
commit 2557dfbc3b
3 changed files with 49 additions and 40 deletions

View File

@@ -519,7 +519,22 @@ XPCOM_NATIVE(FinalizeStub) (JNIEnv *env, jclass that, jobject aJavaObject)
if (isCopy)
env->ReleaseStringUTFChars(name, javaObjectName);
#endif
nsISupports* xpcomObj = RemoveXPCOMBinding(env, aJavaObject);
NS_RELEASE(xpcomObj);
void* obj = GetMatchingXPCOMObject(env, aJavaObject);
RemoveJavaXPCOMBinding(env, aJavaObject, nsnull);
nsISupports* xpcom_obj = nsnull;
if (IsXPTCStub(obj)) {
GetXPTCStubAddr(obj)->QueryInterface(NS_GET_IID(nsISupports),
(void**) &xpcom_obj);
} else {
JavaXPCOMInstance* inst = (JavaXPCOMInstance*) obj;
xpcom_obj = inst->GetInstance();
// XXX Getting some odd thread issues when calling delete. Addreffing for
// now to work around the errors.
// NS_ADDREF(inst);
delete inst;
}
NS_RELEASE(xpcom_obj);
}