All Manuals > LispWorks User Guide and Reference Manual > 41 The LW-JI Package

NextPrevUpTopContentsIndex

jobject-ensure-global

Function
Summary

Returns a global jobject pointing to the same Java object as the argument.

Package

lw-ji

Signature

jobject-ensure-global jobject => global-jobject

Arguments

jobject

A jobject.

Values

global-jobject

A jobject.

Description

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.

Notes
  1. jobject-ensure-global cannot access local references outside the right scope (like any other function).
  2. jobject-ensure-global does not accept an instance of standard-java-object.
See also

jobject-p
map-java-object-array
define-lisp-proxy


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex