Returns a global jobject pointing to the same Java object as the argument.
The function jobject-ensure-global
returns a jobject pointing to the same Java object as the argument jobject, but which is guaranteed to be global.
In most cases, jobjects are global anyway. However, when using map-java-object-array, by default, the jobjects are local and cannot be used outside the scope of the function that was passed to map-java-object-array. Similarly, jobjects can be made local inside functions that are invoked by proxies, using the :jobject-scope
option (see define-lisp-proxy). In these situations, if you want to access the Java object outside the scope of the function that was invoked by map-java-object-array or by the proxy, you need to use jobject-ensure-global
inside the scope of the function, and then you can use the result outside the scope of the function.
If the argument jobject is not a jobject an error is signaled.
If the argument jobject is already a global reference, jobject-ensure-global
simply returns it.
jobject-ensure-global
cannot access local references outside the right scope (like any other function).jobject-ensure-global
does not accept an instance of standard-java-object. LispWorks User Guide and Reference Manual - 13 Feb 2015