As a best practice, BEA recommends that you deploy pure Java applications on LiquidVM, since this guarantees the maximum benefit of LiquidVM. However, this does not mean that LiquidVM cannot run native code; in fact, the JVM itself and the OS kernel below it are both native code. Native libraries can be built for LiquidVM and loaded the same way they are loaded for Java in any environment.
Moreover, it is possible to use your shared libraries that are built for Linux on LiquidVM if your library only uses the functions in Linux that LiquidVM also provides. LiquidVM’s native interface is nix-like, but it only implements the functions the JVM needs from the OS because BEA does not provide a fully POSIX-compliant function interface to LiquidVM. LiquidVM’s OS-kernel is developed entirely by BEA and is not a Linux or BSD-derivative, even though some Linux and BSD binaries can be loaded.
Caution:
BEA provides no guarantees and no support for third-party native code that is trying to use functions that are not on the list of officially available functions.
Native Functions That Will Work with LiquidVM
The following list is an overview of the kind of native functions LiquidVM does provide. For a complete list of provided functions, see the Supported Native Code Functions in LiquidVM.
The JVM, JNI, and JVMTI-interface. LiquidVM implements the full JVM, JNI, and JVMTI-specifications as the standards require.
Malloc, calloc and free to allocate and free memory of standard C.
Normal string manipulations functions of standard C (strchr, strcmp, strcpy, memcpy, etc.)
Standard mathematical functions of standard C.
A set of standard functions to do I/O that are used by the JVM and the surrounding native libraries.
Native Functions That Will Not Work with LiquidVM
The following list is an overview of the native functions LiquidVM does not provide. For a complete list of provided native functions, see the Supported Native Code Functions in LiquidVM.
Native code that tries to directly interact with another OS-specific process in the same OS. If this kind of interaction is important to your application, you should not consider LiquidVM.
For example, if the reason you use native code is to access an Excel spreadsheet, LiquidVM will not be able to help you, LiquidVM is a single-process environment.
Another example is communication with MQSeries Transaction Manager, which normally is another process on the same machine. In the LiquidVM case, you can use a MQSeries Transactional Client, which is Java-based to make this work anyhow.
Native code that tries to create another process using exec/fork or an equivalent. LiquidVM is a single-process environment and does not support the creation of additional processes.
Building a Shared Library for LiquidVM
LiquidVM can load 32-bit, x86 shared libraries that follows the ELF-standard. This is the linker format typically used by Linux and BSD OSes. This means that you can compile your shared library for LiquidVM on a Linux system exactly as you would compile a normal library for this OS.
In fact, in many cases an existing shared library for Linux will work for LiquidVM too, as long as the called functions exist in LiquidVM as well.
Loading a Shared Library Inside LiquidVM
Use the following guidelines when loading a shared library inside LiquidVM:
Make the shared library available from LiquidVM (e.g., put it on the LiquidVM local disk).
By default LiquidVM rejects third-party shared libraries; therefore, you will have to tell LiquidVM not to reject your library. The simplest way to do this is to pass in the lnkLibsAllowAll=true argument to the LiquidVM kernel.
Load the shared library the same way you would do on an ordinary OS (e.g., System.loadLibrary(…)).
What Happens If a Shared Library Calls Non-existent Functions?
The shared library will load as normal, but as soon as you try to call a function that does not exist in LiquidVM, the VM will display an error message and a stack-trace of the offending call, and will then shut down.
Supported Native Code Functions in LiquidVM
Table A-1 lists the native code functions that are supported in LiquidVM.