Could not deal with local reference (local link) when working in native code via JNI. I know that local links can be converted to global (NewGlobalRef). I know that local links can be deleted by yourself (DeleteLocalRef). But explain, pliz, incomprehensible to me moments:

1) If we call the native-function from the java-code and get some jobject as a parameter of the native-function, it is obtained as a local link and this link is deleted after exiting that native-function. This is clear to me.

2) If we call the native-function from java-code and get a jobject inside this native-function as a result of calling one of the java-methods, then it is also a local reference. But what is the life cycle of this local link and who, when and how is responsible for it? Is the life cycle of a local link related to the output from the native function in which it is received or not? It seems that the virtual machine knows nothing about where exactly the link was obtained and therefore the link life cycle is not associated with this native-function? It turns out absolutely all local links obtained in this way need to delete yourself? Or is there some kind of “destructor” inside the “local link” object, in which, for example, DeleteLocalRef is implicitly called for this link when the “local link” object is deleted in the native code?

3) If we call the native-function from the java-code and run the native-stream inside it and get the jobject from the java-method already inside it, is this situation and the life cycle of the local link different from clause 2?

4) What is the local reference table and what is it connected with? Does it refer to any stream or only to a native stream or to something else?

    0