Bug 1187552 - Support direct ownership of C++ objects by Java objects; r=snorp
Add a direct ownership model where the Java object owns the corresponding C++ object directly, in addition to the WeakPtr model where the Java object owns a WeakPtr to the C++ object. The WeakPtr model is chosen when the implementing C++ class inherits from SupportsWeakPtr. Otherwise, the direct ownership model is chosen. Under the direct ownership model, a UniquePtr object must be used to attach the containing C++ object to a Java object, to ensure ownership is passed on to the Java object.
This commit is contained in:
@@ -111,14 +111,8 @@ uintptr_t GetNativeHandle(JNIEnv* env, jobject instance)
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto handle = static_cast<uintptr_t>(
|
||||
return static_cast<uintptr_t>(
|
||||
env->GetLongField(instance, sJNIObjectHandleField));
|
||||
|
||||
if (!handle && !env->ExceptionCheck()) {
|
||||
ThrowException(env, "java/lang/NullPointerException",
|
||||
"Null native pointer");
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
void SetNativeHandle(JNIEnv* env, jobject instance, uintptr_t handle)
|
||||
|
||||
Reference in New Issue
Block a user