Comparing PBNI and JNI
If you have used the Java Native Interface (JNI), which allows Java applications and C and C++ modules to interoperate, you might find it helpful to be aware of the similarities in the two interfaces and the differences between them.
The IPB_VM interface in PBNI is analogous to the JavaVM type, and the IPB_Session interface in PBNI is analogous to JNIEnv. For JNI, you use the javap command to obtain a string that encodes the signature of each method in a native class. For PBNI, the pbsig125 tool performs the same function.
The major difference between the two interfaces is in how a native function or class is declared.
In JNI, you must use the native keyword to declare that a
function is native, but you cannot simply declare a class as native.
You must define your classes in Java source code, use the javah tool
to generate a C header file that defines a C prototype for each
native method, then implement the individual C or C++ functions,
using #include
to
include the generated header file.
PBNI provides an object-oriented approach—you declare a class as native in the C++ code by inheriting from the IPBX_NonVisualObject or IPBX_VisualObject struct.