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

get-host-java-virtual-machine Function

Summary

Return the host Java virtual machine in a dynamic library loaded by Java.

Package

lw-ji

Signature

get-host-java-virtual-machine => jvm

Values
jvm
A java-vm-poi or nil.
Description

The function get-host-java-virtual-machine returns the host Java virtual machine when it is called in a dynamic library that was delivered with a call setup-deliver-dynamic-library-for-java, and the dynamic library was loaded by Java. In all other circumstances it returns nil.

If the initialization of the Java interface is synchronous, which is determined the asynchronous argument of setup-deliver-dynamic-library-for-java and is the default, then during the call to the deliver startup function (the first argument ot deliver), get-host-java-virtual-machine still returns nil. It is guaranteed to return the correct value only when the function argument of setup-deliver-dynamic-library-for-java (if any) is called. In the asynchronous case, get-host-java-virtual-machine always returns the correct value.

The result jvm, when it is not nil, is an object of type java-vm-poi.

get-host-java-virtual-machine is useful as a predicate to determine if the library was loaded by Java or non-Java code.

Notes

get-host-java-virtual-machine can find the virtual machine because Java calls JNI_OnLoad with it. If a non-Java code calls JNI_OnLoad with something else, then get-host-java-virtual-machine will return that something else.

When init-java-interface is called without a specified Java virtual machine, it uses get-host-java-virtual-machine to try to find the current one.

See also

setup-deliver-dynamic-library-for-java
init-java-interface
15 Java interface


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:46