This chapter serves as the reference section for the JNI functions. It provides a
complete listing of all the JNI functions. It also presents the exact layout of the
JNI function table.
Note the use of the term "must" to describe restrictions on JNI programmers.
For example, when you see that a certain JNI function must receive a non-NULL
object, it is your responsibility to ensure that NULL is not passed to that JNI
function. As a result, a JNI implementation does not need to perform NULL
pointer checks in that JNI function.
A portion of this chapter is adapted from Netscape's JRI documentation.
The reference material groups functions by their usage. The reference section is
organized by the following functional areas:
Each function is accessible at a fixed offset through the JNIEnv argument. The
JNIEnv type is a pointer to a structure storing all JNI function pointers. It is
defined as follows:
typedef const struct JNINativeInterface *JNIEnv;
The VM initializes the function table, as shown by Code Example 4-1. Note that
the first three entries are reserved for future compatibility with COM. In
addition, we reserve a number of additional NULL entries near the beginning of
the function table, so that, for example, a future class-related JNI operation can
be added after FindClass, rather than at the end of the table.
Note that the function table can be shared among all JNI interface pointers.
Code Example 4-1
const struct JNINativeInterface ... = {
NULL,
NULL,
NULL,
NULL,
GetVersion,
DefineClass,
FindClass,
NULL,
NULL,
NULL,
GetSuperclass,
IsAssignableFrom,
NULL,
Throw,
ThrowNew,
ExceptionOccurred,
ExceptionDescribe,
ExceptionClear,
FatalError,
NULL,
NULL,
NewGlobalRef,
DeleteGlobalRef,
DeleteLocalRef,
IsSameObject,
NULL,
NULL,
AllocObject,
NewObject,
NewObjectV,
NewObjectA,
GetObjectClass,
IsInstanceOf,
GetMethodID,
CallObjectMethod,
CallObjectMethodV,
CallObjectMethodA,
CallBooleanMethod,
CallBooleanMethodV,
CallBooleanMethodA,
CallByteMethod,
CallByteMethodV,
CallByteMethodA,
CallCharMethod,
CallCharMethodV,
CallCharMethodA,
CallShortMethod,
CallShortMethodV,
CallShortMethodA,
CallIntMethod,
CallIntMethodV,
CallIntMethodA,
CallLongMethod,
CallLongMethodV,
CallLongMethodA,
CallFloatMethod,
CallFloatMethodV,
CallFloatMethodA,
CallDoubleMethod,
CallDoubleMethodV,
CallDoubleMethodA,
CallVoidMethod,
CallVoidMethodV,
CallVoidMethodA,
CallNonvirtualObjectMethod,
CallNonvirtualObjectMethodV,
CallNonvirtualObjectMethodA,
CallNonvirtualBooleanMethod,
CallNonvirtualBooleanMethodV,
CallNonvirtualBooleanMethodA,
CallNonvirtualByteMethod,
CallNonvirtualByteMethodV,
CallNonvirtualByteMethodA,
CallNonvirtualCharMethod,
CallNonvirtualCharMethodV,
CallNonvirtualCharMethodA,
CallNonvirtualShortMethod,
CallNonvirtualShortMethodV,
CallNonvirtualShortMethodA,
CallNonvirtualIntMethod,
CallNonvirtualIntMethodV,
CallNonvirtualIntMethodA,
CallNonvirtualLongMethod,
CallNonvirtualLongMethodV,
CallNonvirtualLongMethodA,
CallNonvirtualFloatMethod,
CallNonvirtualFloatMethodV,
CallNonvirtualFloatMethodA,
CallNonvirtualDoubleMethod,
CallNonvirtualDoubleMethodV,
CallNonvirtualDoubleMethodA,
CallNonvirtualVoidMethod,
CallNonvirtualVoidMethodV,
CallNonvirtualVoidMethodA,
GetFieldID,
GetObjectField,
GetBooleanField,
GetByteField,
GetCharField,
GetShortField,
GetIntField,
GetLongField,
GetFloatField,
GetDoubleField,
SetObjectField,
SetBooleanField,
SetByteField,
SetCharField,
SetShortField,
SetIntField,
SetLongField,
SetFloatField,
SetDoubleField,
GetStaticMethodID,
CallStaticObjectMethod,
CallStaticObjectMethodV,
CallStaticObjectMethodA,
CallStaticBooleanMethod,
CallStaticBooleanMethodV,
CallStaticBooleanMethodA,
CallStaticByteMethod,
CallStaticByteMethodV,
CallStaticByteMethodA,
CallStaticCharMethod,
CallStaticCharMethodV,
CallStaticCharMethodA,
CallStaticShortMethod,
CallStaticShortMethodV,
CallStaticShortMethodA,
CallStaticIntMethod,
CallStaticIntMethodV,
CallStaticIntMethodA,
CallStaticLongMethod,
CallStaticLongMethodV,
CallStaticLongMethodA,
CallStaticFloatMethod,
CallStaticFloatMethodV,
CallStaticFloatMethodA,
CallStaticDoubleMethod,
CallStaticDoubleMethodV,
CallStaticDoubleMethodA,
CallStaticVoidMethod,
CallStaticVoidMethodV,
CallStaticVoidMethodA,
GetStaticFieldID,
GetStaticObjectField,
GetStaticBooleanField,
GetStaticByteField,
GetStaticCharField,
GetStaticShortField,
GetStaticIntField,
GetStaticLongField,
GetStaticFloatField,
GetStaticDoubleField,
SetStaticObjectField,
SetStaticBooleanField,
SetStaticByteField,
SetStaticCharField,
SetStaticShortField,
SetStaticIntField,
SetStaticLongField,
SetStaticFloatField,
SetStaticDoubleField,
NewString,
GetStringLength,
GetStringChars,
ReleaseStringChars,
NewStringUTF,
GetStringUTFLength,
GetStringUTFChars,
ReleaseStringUTFChars,
GetArrayLength,
NewObjectArray,
GetObjectArrayElement,
SetObjectArrayElement,
NewBooleanArray,
NewByteArray,
NewCharArray,
NewShortArray,
NewIntArray,
NewLongArray,
NewFloatArray,
NewDoubleArray,
GetBooleanArrayElements,
GetByteArrayElements,
GetCharArrayElements,
GetShortArrayElements,
GetIntArrayElements,
GetLongArrayElements,
GetFloatArrayElements,
GetDoubleArrayElements,
ReleaseBooleanArrayElements,
ReleaseByteArrayElements,
ReleaseCharArrayElements,
ReleaseShortArrayElements,
ReleaseIntArrayElements,
ReleaseLongArrayElements,
ReleaseFloatArrayElements,
ReleaseDoubleArrayElements,
GetBooleanArrayRegion,
GetByteArrayRegion,
GetCharArrayRegion,
GetShortArrayRegion,
GetIntArrayRegion,
GetLongArrayRegion,
GetFloatArrayRegion,
GetDoubleArrayRegion,
SetBooleanArrayRegion,
SetByteArrayRegion,
SetCharArrayRegion,
SetShortArrayRegion,
SetIntArrayRegion,
SetLongArrayRegion,
SetFloatArrayRegion,
SetDoubleArrayRegion,
RegisterNatives,
UnregisterNatives,
MonitorEnter,
MonitorExit,
GetJavaVM,
};
Version Information
GetVersion
jint GetVersion(JNIEnv *env);
Returns the version of the native method interface.
PARAMETERS:
env: the JNI interface pointer.
RETURNS:
Returns the major version number in the higher 16 bits and the minor version
number in the lower 16 bits.
loader: a class loader assigned to the defined class.
buf: buffer containing the .class file data.
bufLen: buffer length.
RETURNS:
Returns a Java class object or NULL if an error occurs.
THROWS:
ClassFormatError: if the class data does not specify a valid class.
ClassCircularityError: if a class or interface would be its own superclass
or superinterface.
OutOfMemoryError: if the system runs out of memory.
FindClass
jclass FindClass(JNIEnv *env, const char *name);
This function loads a locally-defined class. It searches the directories and zip
files specified by the CLASSPATH environment variable for the class with the
specified name.
PARAMETERS:
env: the JNI interface pointer.
name: a fully-qualified class name (that is, a package name, delimited by "/",
followed by the class name). If the name begins with "[" (the array signature
character), it returns an array class.
RETURNS:
Returns a class object from a fully-qualified name, or NULL if the class cannot
be found.
THROWS:
ClassFormatError: if the class data does not specify a valid class.
ClassCircularityError: if a class or interface would be its own superclass
or superinterface.
NoClassDefFoundError: if no definition for a requested class or interface
can be found.
OutOfMemoryError: if the system runs out of memory.
GetSuperclass
jclass GetSuperclass(JNIEnv *env, jclass clazz);
If clazz represents any class other than the class Object, then this function
returns the object that represents the superclass of the class specified by clazz.
If clazz specifies the class Object, or clazz represents an interface, this
function returns NULL.
PARAMETERS:
env: the JNI interface pointer.
clazz: a Java class object.
RETURNS:
Returns the superclass of the class represented by clazz, or NULL.
Constructs an exception object from the specified class with the message
specified by message and causes that exception to be thrown.
PARAMETERS:
env: the JNI interface pointer.
clazz: a subclass of java.lang.Throwable.
message: the message used to construct the java.lang.Throwable object.
RETURNS:
Returns 0 on success; a negative value on failure.
THROWS:
the newly constructed java.lang.Throwable object.
ExceptionOccurred
jthrowable ExceptionOccurred(JNIEnv *env);
Determines if an exception is being thrown. The exception stays being thrown
until either the native code calls ExceptionClear(), or the Java code handles
the exception.
PARAMETERS:
env: the JNI interface pointer.
RETURNS:
Returns the exception object that is currently in the process of being thrown, or
NULL if no exception is currently being thrown.
ExceptionDescribe
void ExceptionDescribe(JNIEnv *env);
Prints an exception and a backtrace of the stack to a system error-reporting
channel, such as stderr. This is a convenience routine provided for
debugging.
PARAMETERS:
env: the JNI interface pointer.
ExceptionClear
void ExceptionClear(JNIEnv *env);
Clears any exception that is currently being thrown. If no exception is currently
being thrown, this routine has no effect.
PARAMETERS:
env: the JNI interface pointer.
FatalError
void FatalError(JNIEnv *env, const char *msg);
Raises a fatal error and does not expect the VM to recover. This function does
not return.
PARAMETERS:
env: the JNI interface pointer.
msg: an error message.
Global and Local References
NewGlobalRef
jobject NewGlobalRef(JNIEnv *env, jobject obj);
Creates a new global reference to the object referred to by the obj argument.
The obj argument may be a global or local reference. Global references must
be explicitly disposed of by calling DeleteGlobalRef().
PARAMETERS:
env: the JNI interface pointer.
obj: a global or local reference.
RETURNS:
Returns a global reference, or NULL if the system runs out of memory.
Constructs a new Java object. The method ID indicates which constructor
method to invoke. This ID must be obtained by calling GetMethodID() with
<init> as the method name and void (V) as the return type.
The clazz argument must not refer to an array class.
NewObject
Programmers place all arguments that are to be passed to the constructor
immediately following the methodID argument. NewObject() accepts these
arguments and passes them to the Java method that the programmer wishes to
invoke.
NewObjectA
Programmers place all arguments that are to be passed to the constructor in an
args array of jvalues that immediately follows the methodID argument.
NewObjectA() accepts the arguments in this array, and, in turn, passes them
to the Java method that the programmer wishes to invoke.
NewObjectV
Programmers place all arguments that are to be passed to the constructor in an
args argument of type va_list that immediately follows the methodID
argument. NewObjectV() accepts these arguments, and, in turn, passes them
to the Java method that the programmer wishes to invoke.
PARAMETERS:
env: the JNI interface pointer.
clazz: a Java class object.
methodID: the method ID of the constructor.
Additional Parameter for NewObject:
arguments to the constructor.
Additional Parameter for NewObjectA:
args: an array of arguments to the constructor.
Additional Parameter for NewObjectV:
args: a va_list of arguments to the constructor.
RETURNS:
Returns a Java object, or NULL if the object cannot be constructed.
THROWS:
InstantiationException: if the class is an interface or an abstract class.
OutOfMemoryError: if the system runs out of memory.
Returns the field ID for an instance (nonstatic) field of a class. The field is
specified by its name and signature. The Get<type>Field and Set<type>Field
families of accessor functions use field IDs to retrieve object fields.
GetFieldID() causes an uninitialized class to be initialized.
GetFieldID() cannot be used to obtain the length field of an array. Use
GetArrayLength() instead.
PARAMETERS:
env: the JNI interface pointer.
clazz: a Java class object.
name: the field name in a 0-terminated UTF-8 string.
sig: the field signature in a 0-terminated UTF-8 string.
RETURNS:
Returns a field ID, or NULL if the operation fails.
THROWS:
NoSuchFieldError: if the specified field cannot be found.
ExceptionInInitializerError: if the class initializer fails due to an
exception.
OutOfMemoryError: if the system runs out of memory.
This family of accessor routines returns the value of an instance (nonstatic)
field of an object. The field to access is specified by a field ID obtained by
calling GetFieldID().
The following table describes the Get<type>Field routine name and result type.
You should replace type in Get<type>Field with the Java type of the field, or use
one of the actual routine names from the table, and replace NativeType with the
corresponding native type for that routine.
Table 4-1 Get<type>Field Family of Accessor Routines
This family of accessor routines sets the value of an instance (nonstatic) field of
an object. The field to access is specified by a field ID obtained by calling
GetFieldID().
The following table describes the Set<type>Field routine name and value type.
You should replace type in Set<type>Field with the Java type of the field, or use
one of the actual routine names from the table, and replace NativeType with the
corresponding native type for that routine.
Table 4-2 Set<type>Field Family of Accessor Routines
Returns the method ID for an instance (nonstatic) method of a class or
interface. The method may be defined in one of the clazz's superclasses and
inherited by clazz. The method is determined by its name and signature.
GetMethodID() causes an uninitialized class to be initialized.
To obtain the method ID of a constructor, supply <init> as the method name
and void (V) as the return type.
PARAMETERS:
env: the JNI interface pointer.
clazz: a Java class object.
name: the method name in a 0-terminated UTF-8 string.
sig: the method signature in 0-terminated UTF-8 string.
RETURNS:
Returns a method ID, or NULL if the specified method cannot be found.
THROWS:
NoSuchMethodError: if the specified method cannot be found.
ExceptionInInitializerError: if the class initializer fails due to an
exception.
OutOfMemoryError: if the system runs out of memory.
Methods from these three families of operations are used to call a Java instance
method from a native method.They only differ in their mechanism for passing
parameters to the methods that they call.
These families of operations invoke an instance (nonstatic) method on a Java
object, according to the specified method ID. The methodID argument must be
obtained by calling GetMethodID().
When these functions are used to call private methods and constructors, the
method ID must be derived from the real class of obj, not from one of its
superclasses.
Call<type>Method Routines
Programmers place all arguments that are to be passed to the method
immediately following the methodID argument. The Call<type>Method routine
accepts these arguments and passes them to the Java method that the
programmer wishes to invoke.
Call<type>MethodA Routines
Programmers place all arguments to the method in an args array of jvalues
that immediately follows the methodID argument. The Call<type>MethodA
routine accepts the arguments in this array, and, in turn, passes them to the
Java method that the programmer wishes to invoke.
Call<type>MethodV Routines
Programmers place all arguments to the method in an args argument of type
va_list that immediately follows the methodID argument. The
Call<type>MethodV routine accepts the arguments, and, in turn, passes them to
the Java method that the programmer wishes to invoke.
The following table describes each of the method calling routines according to
their result type. You should replace type in Call<type>Method with the Java
type of the method you are calling (or use one of the actual method calling
routine names from the table) and replace NativeType with the corresponding
native type for that routine.
These families of operations invoke an instance (nonstatic) method on a Java
object, according to the specified class and method ID. The methodID
argument must be obtained by calling GetMethodID() on the class clazz.
The CallNonvirtual<type>Method families of routines and the Call<type>Method
families of routines are different. Call<type>Method routines invoke the method
based on the class of the object, while CallNonvirtual<type>Method routines
invoke the method based on the class, designated by the clazz parameter,
from which the method ID is obtained. The method ID must be obtained from
the real class of the object or from one of its superclasses.
CallNonvirtual<type>Method Routines
Programmers place all arguments that are to be passed to the method
immediately following the methodID argument. The
CallNonvirtual<type>Method routine accepts these arguments and passes them
to the Java method that the programmer wishes to invoke.
CallNonvirtual<type>MethodA Routines
Programmers place all arguments to the method in an args array of jvalues
that immediately follows the methodID argument. The
CallNonvirtual<type>MethodA routine accepts the arguments in this array, and,
in turn, passes them to the Java method that the programmer wishes to invoke.
CallNonvirtual<type>MethodV Routines
Programmers place all arguments to the method in an args argument of type
va_list that immediately follows the methodID argument. The
CallNonvirtualMethodV routine accepts the arguments, and, in turn, passes
them to the Java method that the programmer wishes to invoke.
The following table describes each of the method calling routines according to
their result type. You should replace type in CallNonvirtual<type>Method with
the Java type of the method, or use one of the actual method calling routine
names from the table, and replace NativeType with the corresponding native
type for that routine.
Returns the field ID for a static field of a class. The field is specified by its name
and signature. The GetStatic<type>Field and SetStatic<type>Field families of
accessor functions use field IDs to retrieve static fields.
GetStaticFieldID() causes an uninitialized class to be initialized.
PARAMETERS:
env: the JNI interface pointer.
clazz: a Java class object.
name: the static field name in a 0-terminated UTF-8 string.
sig: the field signature in a 0-terminated UTF-8 string.
RETURNS:
Returns a field ID, or NULL if the specified static field cannot be found.
THROWS:
NoSuchFieldError: if the specified static field cannot be found.
ExceptionInInitializerError: if the class initializer fails due to an
exception.
OutOfMemoryError: if the system runs out of memory.
This family of accessor routines returns the value of a static field of an object.
The field to access is specified by a field ID, which is obtained by calling
GetStaticFieldID().
The following table describes the family of get routine names and result types.
You should replace type in GetStatic<type>Field with the Java type of the field,
or one of the actual static field accessor routine names from the table, and
replace NativeType with the corresponding native type for that routine.
Table 4-5 GetStatic<type>Field Family of Accessor Routines
This family of accessor routines sets the value of a static field of an object. The
field to access is specified by a field ID, which is obtained by calling
GetStaticFieldID().
The following table describes the set routine name and value types. You should
replace type in SetStatic<type>Field with the Java type of the field, or one of the
actual set static field routine names from the table, and replace NativeType with
the corresponding native type for that routine.
Table 4-6 SetStatic<type>Field Family of Accessor Routines
This family of operations invokes a static method on a Java object, according to
the specified method ID. The methodID argument must be obtained by calling
GetStaticMethodID().
The method ID must be derived from clazz, not from one of its superclasses.
CallStatic<type>Method Routines
Programmers should place all arguments that are to be passed to the method
immediately following the methodID argument. The CallStatic<type>Method
routine accepts these arguments and passes them to the Java method that the
programmer wishes to invoke.
CallStatic<type>MethodA Routines
Programmers should place all arguments to the method in an args array of
jvalues that immediately follows the methodID argument. The
CallStaticMethodA routine accepts the arguments in this array, and, in turn,
passes them to the Java method that the programmer wishes to invoke.
CallStatic<type>MethodV Routines
Programmers should place all arguments to the method in an args argument
of type va_list that immediately follows the methodID argument. The
CallStaticMethodV routine accepts the arguments, and, in turn, passes them to
the Java method that the programmer wishes to invoke.
The following table describes each of the method calling routines according to
their result types. You should replace type in CallStatic<type>Method with the
Java type of the method, or one of the actual method calling routine names
from the table, and replace NativeType with the corresponding native type for
that routine.
A family of operations used to construct a new primitive array object. Table 4-8
describes the specific primitive array constructors. You should replace
New<PrimitiveType>Array with one of the actual primitive array constructor
routine names from the following table, and replace ArrayType with the
corresponding array type for that routine.
Table 4-8 New<PrimitiveType>Array Family of Array Constructors
New<PrimitiveType>Array Routines
Array Type
NewBooleanArray()
jbooleanArray
NewByteArray()
jbyteArray
NewCharArray()
jcharArray
NewShortArray()
jshortArray
NewIntArray()
jintArray
NewLongArray()
jlongArray
NewFloatArray()
jfloatArray
NewDoubleArray()
jdoubleArray
PARAMETERS:
env: the JNI interface pointer.
length: the array length.
RETURNS:
Returns a Java array, or NULL if the array cannot be constructed.
A family of functions that returns the body of the primitive array. The result is
valid until the corresponding Release<PrimitiveType>ArrayElements() function is
called. Since the returned array may be a copy of the Java array, changes made to the
returned array will not necessarily be reflected in the original arrayuntilRelease<PrimitiveType>ArrayElements()is called.
If isCopy is not NULL, then *isCopy is set to JNI_TRUE if a copy is made; or
it is set to JNI_FALSE if no copy is made.
The following table describes the specific primitive array element accessors.
You should make the following substitutions:
Replace Get<PrimitiveType>ArrayElements with one of the actual primitive
element accessor routine names from the table.
Replace ArrayType with the corresponding array type.
Replace NativeType with the corresponding native type for that routine.
Regardless of how boolean arrays are represented in the Java VM,
GetBooleanArrayElements() always returns a pointer to jbooleans, with
each byte denoting an element (the unpacked representation). All arrays of
other types are guaranteed to be contiguous in memory.
Table 4-9 Get<PrimitiveType>ArrayElements Family of Accessor Routines
Get<PrimitiveType>ArrayElements
Routines
Array Type
Native Type
GetBooleanArrayElements()
jbooleanArray
jboolean
GetByteArrayElements()
jbyteArray
jbyte
GetCharArrayElements()
jcharArray
jchar
GetShortArrayElements()
jshortArray
jshort
GetIntArrayElements()
jintArray
jint
GetLongArrayElements()
jlongArray
jlong
GetFloatArrayElements()
jfloatArray
jfloat
GetDoubleArrayElements()
jdoubleArray
jdouble
PARAMETERS:
env: the JNI interface pointer.
array: a Java string object.
isCopy: a pointer to a boolean.
RETURNS:
Returns a pointer to the array elements, or NULL if the operation fails.
A family of functions that informs the VM that the native code no longer needs
access to elems. The elems argument is a pointer derived from array using
the corresponding Get<PrimitiveType>ArrayElements() function. If necessary,
this function copies back all changes made to elems to the original array.
The mode argument provides information on how the array buffer should be
released. mode has no effect if elems is not a copy of the elements in array.
Otherwise, mode has the following impact, as shown in the following table:
Table 4-10 Primitive Array Release Modes
mode
actions
0
copy back the content and free the elems buffer
JNI_COMMIT
copy back the content but do not free the elems
buffer
JNI_ABORT
free the buffer without copying back the possible
changes
In most cases, programmers pass "0" to the mode argument to ensure
consistent behavior for both pinned and copied arrays. The other options give
the programmer more control over memory management and should be used
with extreme care.
The next table describes the specific routines that comprise the family of
primitive array disposers. You should make the following substitutions:
Replace Release<PrimitiveType>ArrayElements with one of the actual
primitive array disposer routine names from Table 4-11.
Replace ArrayType with the corresponding array type.
Replace NativeType with the corresponding native type for that routine.
Table 4-11 Release<PrimitiveType>ArrayElements Family of Array Routines
Registers native methods with the class specified by the clazz argument. The
methods parameter specifies an array of JNINativeMethod structures that
contain the names, signatures, and function pointers of the native methods.
The nMethods parameter specifies the number of native methods in the array.
The JNINativeMethod structure is defined as follows:
Unregisters native methods of a class. The class goes back to the state before it
was linked or registered with its native method functions.
This function should not be used in normal native code. Instead, it provides
special programs a way to reload and relink native libraries.
PARAMETERS:
env: the JNI interface pointer.
clazz: a Java class object.
RETURNS:
Returns "0" on success; returns a negative value on failure.
Monitor Operations
MonitorEnter
jint MonitorEnter(JNIEnv *env, jobject obj);
Enters the monitor associated with the underlying Java object referred to by
obj.
Each Java object has a monitor associated with it. If the current thread already
owns the monitor associated with obj, it increments a counter in the monitor
indicating the number of times this thread has entered the monitor. If the
monitor associated with obj is not owned by any thread, the current thread
becomes the owner of the monitor, setting the entry count of this monitor to 1.
If another thread already owns the monitor associated with obj, the current
thread waits until the monitor is released, then tries again to gain ownership.
PARAMETERS:
env: the JNI interface pointer.
obj: a normal Java object or class object.
RETURNS:
Returns "0" on success; returns a negative value on failure.
MonitorExit
jint MonitorExit(JNIEnv *env, jobject obj);
The current thread must be the owner of the monitor associated with the
underlying Java object referred to by obj. The thread decrements the counter
indicating the number of times it has entered this monitor. If the value of the
counter becomes zero, the current thread releases the monitor.
PARAMETERS:
env: the JNI interface pointer.
obj: a normal Java object or class object.
RETURNS:
Returns "0" on success; returns a negative value on failure.
Java VM Interface
GetJavaVM
jint GetJavaVM(JNIEnv *env, JavaVM **vm);
Returns the Java VM interface (used in the Invocation API) associated with the
current thread. The result is placed at the location pointed to by the second
argument, vm.
PARAMETERS:
env: the JNI interface pointer.
vm: a pointer to where the result should be placed.
RETURNS:
Returns "0" on success; returns a negative value on failure.