# ANILib -- Asynchronous Native Interface Library

> ANILib, the Asynchronous Native Interface Library, is an add-on package for this Virtual Machine. It provides an API for using native threads in this VM for executing long running native methods.

> ANILib was previously included as an bundled component of this VM. In this release, we have separated out the ANILib functionality into a separate package to improve maintainability and achieve a more modular software design.

## Version Information

> This is version 1.0.1 of ANILib.

## Build Instructions

> This version of ANILib has built-in support for 3 platforms:

> - `win32_i386`
> - `linux_i386`
> - `linux_arm`

> The source code has been structured so that it will be easy to add support for other platforms.

> To build ANILib for your selected platform, you need to follow these steps. (Note the instructions assumes you're building for `linux_i386`.)

> 1. First, you need to build the VM. This can be done by setting up the `JVMWorkSpace` environment variable, and then executing the `gnumake` command inside `$(JVMWorkSpace)/build/linux_i386`.

> 2. Change to the `build/linux_i386` subdirectory of the ANILib source distribution, and execute the `gnumake` command. This produces the following output files:

>    - `build/linux_i386/product/cldc_vm_ani`
>    - `build/linux_i386/product/libani.a`
>    - `build/linux_i386/test_classes/SocketTest.class`

> 3. By default, the `product` variant of ANILib is produced. If you wish to build for other variants, please use commands such as:

>    - `gnumake BUILD=debug`
>    - `gnumake BUILD=release`
>    - `gnumake BUILD=product`

## Running Test Programs

> ANILib comes with a sample program, `SocketTest`, which tests the capabilities of a sample socket protocol. To Execute it, try these commands:

> > `cd build/linux_i386
> > ./product/cldc_vm_ani -cp test_classes SocketTest -host www.sun.com`

> Please read the comments in `src/tests/SocketTest.java` for a complete list of options provided by SocketTest for testing different features in ANILib.

## Linking with ANILib

> To use the `ANI_XXX()` functions exported by ANILib, simply link with `libani.a` (or `ani.lib` for the `win32_i386` platform).

## Changes from Previous Version

> This version of ANILib adds a new API function, `ANI_Initialize()`, which must be called before you use any other ANI functions.

> Also, when your program is about exit, please call `ANI_Dispose()` to free up resources allocated by ANILib.

> When compiling your code, please use the `src/share/ani.h` header file included in this ANILib source distribution.