All Manuals > LispWorks User Guide and Reference Manual > 42 Java classes and methods

NextPrevUpTopContentsIndex

com.lispworks.LispCalls.createLispProxy

Method

public static native Object createLispProxy(String name)

Description

Creates a Lisp proxy, which is a Java proxy which calls Lisp functions.

name specifies a symbol which is the name of a proxy definition, defined in Lisp by either define-lisp-proxy or setup-lisp-proxy. The name is parsed by a simple parser as described for com.lispworks.LispCalls.checkLispSymbol (with fboundp = false).

Once it found the symbol, it makes a proxy the same way that calling make-lisp-proxy with name would, and returns it. The result is an Object that implements all the interfaces that are defined in the proxy definition, and when the methods of these interfaces are called on the object it calls into Lisp. See define-lisp-proxy for details.

If createLispProxy is successful it returns the proxy object. If there is any problem, this will cause a call to cl:error. If the cl:error call is not handled, the java-to-lisp-debugger-hook (see init-java-interface) is called with the condition, and then null is returned from createLispProxy. If the error is handled and tries to throw out of the context of the Lisp side of createLispProxy, the throw is blocked and createLispProxy returns null.

com.lispworks.LispCalls.waitForInitialization

Method

static public boolean waitForInitialization ()

static public boolean waitForInitialization (long seconds)

static public boolean waitForInitialization (long timeout , java.util.concurrent.TimeUnit unit)

Description

Waits for a LispWorks dynamic library to finish initialization and accept foreign calls.

Note: You should not use waitForInitialization on Android. Use the methods in com.lispworks.Manager instead, in particular com.lispworks.Manager.init and com.lispworks.Manager.status.

The method without arguments waits for up to 10000 seconds. The method that takes long waits for up to seconds seconds. The method that takes long and java.util.concurrent.TimeUnit waits for up to the period defined by timeout and unit. See the Java documentation for the possible values of java.util.concurrent.TimeUnit.

waitForInitialization returns when LispWorks has finished its initialization or when the wait period has passed. If LispWorks finishes its initialization first, waitForInitialization returns true. If the wait period has passed, waitForInitialization returns false.

When waitForInitialization is called with 0 seconds, it returns immediately with true if LispWorks is already initialized, and false otherwise. Thus it can be used as a predicate without waiting.

Notes

Until LispWorks finishes its initialization, calls into LispWorks from Java using the other methods in com.lispworks.LispCalls hang, and raise an exception if hanging for too long. If this is an acceptable behavior, then you do not need waitForInitialization. If this is not acceptable, waitForInitialization allows you to check and avoid this situation. Typically your code will do something like:

if (com.lispworks.LispCalls.waitForInitialization(1))
  com.lispworks.LispCalls.callIntV("A-LISP-FUNCTION");
else
  do_something_else();

If the LispWorks dynamic library was created with synchronous initialization (the default), then by the time the loading method (normally System.loadLibrary or System.load) returns, LispWorks has finished initializing. In this case you need waitForInitialization only in code that does not know if the loading method has returned (or even called at all).

If the LispWorks dynamic library was created with asynchronous initialization (setup-deliver-dynamic-library-for-java was called with true for asynchronous), the loading method returns immediately, and LispWorks initializes asynchronously. In this situation you can be sure that LispWorks finished initializing only after a call to waitForInitialization has returned true.

If you don't know how the LispWorks dynamic library was created, just assume that it is asynchronous and always check using waitForInitialization.

See also

setup-deliver-dynamic-library-for-java

 


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex