Package glide.managers
Class JniResponseRegistry
- java.lang.Object
-
- glide.managers.JniResponseRegistry
-
public class JniResponseRegistry extends java.lang.ObjectRegistry for storing Java objects returned from JNI calls. This allows us to pass object IDs through the Response protobuf instead of trying to pass Rust pointers that would become invalid.The registry uses weak references to allow garbage collection when objects are no longer needed.
-
-
Constructor Summary
Constructors Constructor Description JniResponseRegistry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclear()Clear all stored objects.static java.lang.ObjectretrieveAndRemove(long id)Retrieve and remove a Java object by its ID.static intsize()Get the current number of stored objects.static longstoreObject(java.lang.Object object)Store a Java object and return its ID.
-
-
-
Method Detail
-
storeObject
public static long storeObject(java.lang.Object object)
Store a Java object and return its ID. This is used when JNI returns a converted Java object that needs to be passed through the Response protobuf.- Parameters:
object- The Java object to store- Returns:
- The ID that can be used to retrieve the object
-
retrieveAndRemove
public static java.lang.Object retrieveAndRemove(long id)
Retrieve and remove a Java object by its ID. This is called from valueFromPointer to get the actual Java object. The object is removed after retrieval to prevent memory leaks.- Parameters:
id- The ID of the object to retrieve- Returns:
- The Java object, or null if not found
-
clear
public static void clear()
Clear all stored objects. Called during client cleanup.
-
size
public static int size()
Get the current number of stored objects. Useful for debugging and monitoring.
-
-