Contents | Prev | Next | Index The Java Native Interface
Programmer's Guide and Specification


 

A

abort hook , 1, 2
AllocObject , 1, 2
Arnold, Ken , 1
ArrayIndexOutOfBoundsException , 1, 2
arrays , 1
accessing , 1
choosing among functions , 1
efficient access , 1
function summary , 1
multi-dimensional , 1
object vs. primitive , 1
simultaneous access , 1
ASCII strings , 1
asm_dispatch assembly routine , 1
assembly implementation
shared stubs dispatcher , 1
time-critical code , 1
asynchronous exceptions , 1
atol example , 1
attach native threads , 1
attach.c example , 1
AttachCurrentThread , 1, 2

B

binary compatibility , 1
boolean , 1
boundaries of native code , 1
Bracha, Gilad , 1
byte , 1

C

C
calling convention , 1
programming language , 1
C shell , 1
C++
programming language , 1
programming the JNI in , 1
virtual function table , 1
caching field and method IDs , 1
at point of use , 1
in defining class , 1
needed for correctness , 1
Call<Type>Method , 1, 2
Call<Type>MethodA , 1
Call<Type>MethodV , 1
callbacks , 1
CallBooleanMethod , 1
CallBooleanMethodA , 1
CallBooleanMethodV , 1
CallByteMethod , 1
CallByteMethodA , 1
CallByteMethodV , 1
CallCharMethod , 1
CallCharMethodA , 1
CallCharMethodV , 1
CallDoubleMethod , 1
CallDoubleMethodA , 1
CallDoubleMethodV , 1
CallFloatMethod , 1
CallFloatMethodA , 1
CallFloatMethodV , 1
calling conventions , 1
CallIntMethod , 1, 2
CallIntMethodA , 1
CallIntMethodV , 1
CallLongMethod , 1
CallLongMethodA , 1
CallLongMethodV , 1
CallNonvirtual<Type>Method , 1, 2
CallNonvirtual<Type>MethodA , 1
CallNonvirtual<Type>MethodV , 1
CallNonvirtualBooleanMethod , 1, 2
CallNonvirtualBooleanMethodA , 1
CallNonvirtualBooleanMethodV , 1
CallNonvirtualByteMethod , 1
CallNonvirtualByteMethodA , 1
CallNonvirtualByteMethodV , 1
CallNonvirtualCharMethod , 1
CallNonvirtualCharMethodA , 1
CallNonvirtualCharMethodV , 1
CallNonvirtualDoubleMethod , 1
CallNonvirtualDoubleMethodA , 1
CallNonvirtualDoubleMethodV , 1
CallNonvirtualFloatMethod , 1
CallNonvirtualFloatMethodA , 1
CallNonvirtualFloatMethodV , 1
CallNonvirtualIntMethod , 1
CallNonvirtualIntMethodA , 1
CallNonvirtualIntMethodV , 1
CallNonvirtualLongMethod , 1
CallNonvirtualLongMethodA , 1
CallNonvirtualLongMethodV , 1
CallNonvirtualObjectMethod , 1
CallNonvirtualObjectMethodA , 1
CallNonvirtualObjectMethodV , 1
CallNonvirtualShortMethod , 1
CallNonvirtualShortMethodA , 1
CallNonvirtualShortMethodV , 1
CallNonvirtualVoidMethod , 1, 2
CallNonvirtualVoidMethodA , 1
CallNonvirtualVoidMethodV , 1
CallObjectMethod , 1, 2
CallObjectMethodA , 1
CallObjectMethodV , 1
CallShortMethod , 1
CallShortMethodA , 1
CallShortMethodV , 1
CallStatic<Type>Method , 1
CallStatic<Type>MethodA , 1
CallStatic<Type>MethodV , 1
CallStaticBooleanMethod , 1, 2
CallStaticBooleanMethodA , 1
CallStaticBooleanMethodV , 1
CallStaticByteMethod , 1
CallStaticByteMethodA , 1
CallStaticByteMethodV , 1
CallStaticCharMethod , 1
CallStaticCharMethodA , 1
CallStaticCharMethodV , 1
CallStaticDoubleMethod , 1
CallStaticDoubleMethodA , 1
CallStaticDoubleMethodV , 1
CallStaticFloatMethod , 1
CallStaticFloatMethodA , 1
CallStaticFloatMethodV , 1
CallStaticIntMethod , 1
CallStaticIntMethodA , 1
CallStaticIntMethodV , 1
CallStaticLongMethod , 1
CallStaticLongMethodA , 1
CallStaticLongMethodV , 1
CallStaticObjectMethod , 1
CallStaticObjectMethodA , 1
CallStaticObjectMethodV , 1
CallStaticShortMethod , 1
CallStaticShortMethodA , 1
CallStaticShortMethodV , 1
CallStaticVoidMethod , 1, 2
CallStaticVoidMethodA , 1
CallStaticVoidMethodV , 1
CallVoidMethod , 1, 2
CallVoidMethodA , 1
CallVoidMethodV , 1
CatchThrow example , 1
cc
See Solaris C compiler1
CFunction class
callInt method
implementation , 1
use of , 1
implementation , 1
use of , 1
char , 1, 2
cl
See Microsoft Visual C++ compiler1
class descriptors , 1, 2
class loaders
bootstrap loader , 1
defining loader , 1
delegation , 1
garbage collection , 1
JNI_OnUnload handler , 1
type safety , 1
ClassCircularityError , 1, 2
classes , 1, 2
descriptors , 1
load through the JNI , 1
ClassFormatError , 1, 2
ClassLoader.defineClass , 1
ClassLoader.findLibrary , 1
ClassLoader.loadClass , 1
CLASSPATH , 1
CMalloc class
free method , 1
implementation , 1
use of , 1
code examples
atol , 1
attach.c , 1
CacheThrow , 1
CFunction , 1
CMalloc , 1
CPointer , 1
HelloWorld , 1
InstanceFieldAccess , 1, 2
InstanceMethodCall , 1, 2
IntArray , 1, 2, 3
invoke.c , 1
KeyInput , 1
MyNewString , 1, 2, 3, 4, 5
ObjectArrayTest , 1
Prompt , 1, 2, 3
StaticFieldAccess , 1
StaticMethodCall , 1
web download address , 1
Win32.CreateFile , 1, 2
command-line options , 1
constants , 1
constructors , 1
See also NewObject , 1
invoking , 1
CPointer class
copyIn method , 1
definition , 1
implementation , 1
CreateFileA and CreateFileW , 1
csh , 1

D

-D command line option , 1
-Djava.class.path , 1
-Djava.library.path , 1
data types
definitions , 1
mapping , 1
passing , 1
deadlocks
by GetPrimitiveArrayCritical , 1
by GetStringCritical , 1
DefineClass , 1
defining loader , 1
delegation , 1
DeleteGlobalRef , 1
DeleteGlobalWeakRef , 1
DeleteLocalRef , 1, 2
DeleteWeakGlobalRef , 1, 2, 3
descriptors
class
See class descriptors1
field
See field descriptors1
method
See method descriptors1
DestroyJavaVM , 1, 2
DetachCurrentThread , 1, 2
DLL
See dynamic link library1
dlopen , 1
dlsym , 1
double , 1
dynamic link library , 1

E

EnsureLocalCapacity , 1, 2
escape sequences
in name encoding , 1
in UTF-8 strings , 1
example programs
See code examples1
ExceptionCheck , 1, 2
ExceptionClear , 1, 2
ExceptionDescribe , 1, 2
ExceptionInInitializerError , 1, 2, 3, 4, 5
ExceptionOccurred , 1, 2
exceptions
asynchronous , 1
checking for , 1, 2
handling , 1, 2
in utility functions , 1
pending , 1, 2, 3
vs. programmer errors , 1
exit hook , 1, 2

F

FatalError , 1
field descriptors , 1, 2
javap -s , 1
field IDs , 1, 2, 3
caching , 1, 2
resolving , 1
fields
accessing , 1
accessing static vs. instance , 1
descriptor
See field descriptors1
instance
See instance fields1
name , 1
static
See static fields1
file descriptors , 1
FileDescriptor class , 1
final access control , 1
finalize , 1
See also finalizers1
finalizers
freeing native peers , 1
JNI_OnUnload , 1
FindClass , 1, 2
findLibrary
See ClassLoader.findLibrary1
float , 1, 2
foreign function interface , 1
FORTRAN , 1
free
global references , 1
local references , 1
native peer resources , 1
virtual machine resources , 1
FromReflectedField , 1, 2
FromReflectedMethod , 1, 2

G

-G option to cc , 1
garbage collection
class loaders , 1
copy objects , 1
and native method interface , 1
relocating objects , 1
weak global references , 1
Get<Type>ArrayElements , 1, 2, 3
Get<Type>ArrayRegion , 1, 2
Get<Type>Field , 1
GetArrayLength , 1, 2, 3
GetBooleanArrayElements , 1
GetBooleanArrayRegion , 1
GetBooleanField , 1
GetByteArrayElements , 1
GetByteArrayRegion , 1
GetByteField , 1
GetCharArrayElements , 1
GetCharArrayRegion , 1
GetCharField , 1
GetDoubleArrayElements , 1
GetDoubleArrayRegion , 1
GetDoubleField , 1
GetEnv , 1, 2, 3
GetFieldID , 1, 2, 3
GetFloatArrayElements , 1
GetFloatArrayRegion , 1
GetFloatField , 1
GetIntArrayElements , 1, 2
GetIntArrayRegion , 1, 2, 3
GetIntField , 1, 2, 3
GetJavaVM , 1, 2
GetLongArrayElements , 1
GetLongArrayRegion , 1
GetLongField , 1
GetMethodID , 1, 2
GetObjectArrayElement , 1, 2
GetObjectClass , 1, 2, 3
GetObjectField , 1, 2
GetPrimitiveArrayCritical , 1, 2, 3, 4
GetProcAddress Win32 API , 1, 2
GetShortArrayElements , 1
GetShortArrayRegion , 1
GetShortField , 1
GetStatic<Type>Field , 1
GetStaticBooleanField , 1
GetStaticByteField , 1
GetStaticCharField , 1
GetStaticDoubleField , 1
GetStaticFieldID , 1, 2
GetStaticFloatField , 1
GetStaticIntField , 1, 2
GetStaticLongField , 1
GetStaticMethodID , 1, 2
GetStaticObjectField , 1
GetStaticShortField , 1
GetStringChars , 1
GetStringChars , 1, 2, 3
GetStringCritical , 1, 2, 3
GetStringLength , 1, 2, 3
GetStringRegion , 1, 2, 3
GetStringUTFChars , 1, 2, 3, 4
GetStringUTFLength , 1, 2
GetStringUTFRegion , 1, 2, 3
GetSuperclass , 1, 2
GetVersion , 1
global references , 1, 2
freeing , 1
Gosling, James , 1
Green threads , 1, 2

H

HANDLE Win32 type , 1
HelloWorld example , 1
host environment , 1
See also Java platform1
HTTP server , 1

I

IDs vs. references , 1
IllegalAccessException , 1
IllegalArgumentException , 1
IllegalMonitorStateException , 1, 2
initIDs , 1
inlining
final field access , 1
native methods , 1, 2
instance fields , 1
procedure for accessing , 1
instance methods , 1
calling, of superclass , 1
native , 1
steps for calling , 1
InstanceFieldAccess example , 1, 2
InstanceMethodCall example , 1, 2
instances , 1
virtual machine , 1
InstantiationException , 1, 2, 3, 4
int , 1, 2
IntArray example , 1, 2, 3
interfaces
calling methods , 1
obtaining , 1
internationalized code , 1, 2
invocation interface , 1, 2
invoke.c example , 1
IsAssignableFrom , 1, 2
isCopy argument , 1
release resources , 1
IsInstanceOf , 1, 2
IsSameObject , 1, 2, 3

J

jarray , 1, 2
Java 2 SDK , 1
Java API
See Java Application Programming Interface1
Java application , 1
See also native application1
Java Application Programming Interface , 1
Java Core Reflection API , 1
Java Development Kit , 1
Java Native Interface , 1
alternative solutions , 1
benefits , 1
design goals , 1
function table , 1
functions , 1
implications of using , 1
performance characteristics , 1
role of , 1
version evolution , 1, 2
when to use , 1
Java platform , 1
See also host environment1
Java programming language , 1
Java Runtime Environment , 1
java runtime interpreter , 1, 2
Java virtual machine , 1
instance , 1
Java weak references API , 1
java.class.path property , 1
java.io.FileDescriptor , 1
java.lang.Class , 1
java.lang.ClassLoader , 1
java.lang.Float , 1
java.lang.Integer , 1
java.lang.reflect package , 1
java.lang.reflect.Constructor , 1, 2
java.lang.reflect.Field , 1, 2
java.lang.reflect.Method , 1, 2
java.lang.String
See String1
java.lang.Thread , 1
java.library.path property , 1, 2
Java/Java call , 1
Java/native call , 1
Java_ prefix , 1
Java_VMInitArgs , 1
javac compiler , 1, 2
javah tool , 1, 2, 3
javai.dll , 1
javai.lib , 1
javap tool , 1
JavaVM interface
create , 1
destroy , 1
obtaining pointer to , 1
JavaVMAttachArgs , 1
JavaVMInitArgs , 1
JavaVMOption , 1
jboolean , 1
accidentally truncated , 1
jbooleanArray , 1, 2
jbyte , 1
jbyteArray , 1, 2
jchar , 1
jcharArray , 1, 2
jclass , 1, 2
jclass vs. jobject , 1
JDK
See Java Development Kit1
JDK1_1InitArgs , 1, 2
jdouble , 1
jdoubleArray , 1, 2
jfieldID , 1
jfloat , 1, 2
jfloatArray , 1, 2
jint , 1, 2
jintArray , 1, 2
JIT compiler
See just-in-time compiler1
jlong , 1
jlongArray , 1, 2
jmethodID , 1
JNI
See Java Native Interface1
jni.h header file , 1, 2
JNI_ABORT constant , 1, 2
JNI_AttachCurrentThread , 1
JNI_COMMIT constant , 1, 2
JNI_CreateJavaVM , 1, 2
JNI_EDETACHED constant , 1, 2
JNI_ERR constant , 1
JNI_EVERSION constant , 1, 2
JNI_FALSE constant , 1
JNI_GetCreatedJavaVMs , 1, 2
JNI_GetDefaultJavaVMInitArgs , 1, 2
JNI_NativeMethod , 1
JNI_OK constant , 1
JNI_OnLoad , 1, 2, 3
JNI_OnUnload , 1, 2
JNI_ThreadAttachArgs , 1
JNI_TRUE constant , 1
JNI_VERSION_1_1 constant , 1
JNI_VERSION_1_2 constant , 1, 2, 3
JNICALL macro , 1, 2
JNIEnv , 1
benefits , 1
obtaining pointer to , 1
organization , 1
thread-local , 1, 2
JNIEnv2 , 1
JNIEXPORT macro , 1, 2
JNU_CallMethodByName , 1, 2
JNU_FindCreateJavaVM , 1
JNU_GetEnv , 1
JNU_GetStringNativeChars , 1, 2, 3
JNU_MonitorNotify , 1
JNU_MonitorNotifyAll , 1
JNU_MonitorWait , 1
JNU_NewStringNative , 1, 2
JNU_ThrowByName , 1
jobject , 1, 2, 3
jobjectArray , 1, 2, 3
JRE
See Java Runtime Environment1
jshort , 1
jshortArray , 1, 2
jsize , 1
jstring , 1, 2, 3
jthrowable , 1, 2
just-in-time compiler , 1
jvalue union type , 1
jvm.dll , 1
jvm.lib , 1

K

kernel32.dll , 1
Kernighan, Brian , 1
KeyInput example , 1
KornShell , 1
ksh , 1

L

-LD option to cl , 1
LD_LIBRARY_PATH , 1, 2, 3
Lea, Doug , 1
Liang, Sheng , 1
libjava.so , 1
libjvm.so , 1
-link option to cl , 1
linking
native applications , 1
native methods , 1
LISP , 1
-ljava option to cc , 1
loadLibrary
See System.loadLibrary1
LoadLibrary Win32 API , 1, 2
local references , 1, 2
1.2-specific functions , 1
excessive creation , 1
See also -verbose:jni option1
freeing , 1
how to implement , 1
how to invalidate , 1
registry , 1
thread-local , 1
validity of , 1
locale , 1
long , 1
longjmp , 1
-lthread option to cc , 1

M

mapLibraryName
See System.mapLibraryName1
-MD option to cl , 1
memory leaks , 1
method descriptors , 1, 2
javap -s , 1
method IDs , 1, 2
caching , 1, 2
resolving , 1
methods
calling , 1
descriptor
See method descriptors1
in superclasses , 1
instance
See instance methods1
static
See static methods1
Microsoft COM interface , 1, 2, 3
Microsoft Visual C++ compiler , 1
MonitorEnter , 1, 2
monitorenter instruction , 1, 2
MonitorExit , 1, 2
monitorexit instruction , 1
monitors , 1
msvcrt.dll , 1
mutex_lock , 1
MyNewString example , 1, 2, 3, 4, 5

N

name encoding
long , 1, 2
short , 1
namespaces , 1
native application , 1
See also Java application1
native code , 1
See also C, C++1
native library , 1
creation , 1
loading , 1
shared library , 1
unloading , 1
native library path
See also -Djava.library.path1
setting , 1
native method , 1
arguments , 1
declaration , 1
differences with regular methods , 1
implementation
See also javah tool1
function prototype , 1
header files , 1
name encoding , 1
linking , 1
registering , 1
steps in writing and running , 1
native method interface , 1
See also Java Native Interface1
compatibility among releases , 1
problems in JDK 1.0 , 1
native modifier , 1
native programming languages , 1
native thread model , 1
native/Java callback , 1
New<Type>Array , 1, 2
NewBooleanArray , 1
NewByteArray , 1
NewCharArray , 1, 2
NewDoubleArray , 1
NewFloatArray , 1
NewGlobalRef , 1, 2
NewGlobalWeakRef , 1
NewIntArray , 1
NewLocalRef , 1, 2
NewLongArray , 1
NewObject , 1, 2
NewObjectA , 1
NewObjectArray , 1, 2
NewObjectV , 1
NewShortArray , 1
NewString , 1, 2
NewStringUTF , 1, 2, 3
NewWeakGlobalRef , 1, 2
NoClassDefFoundError , 1, 2, 3
NoSuchFieldError , 1, 2
NoSuchMethodError , 1, 2, 3, 4

O

object array , 1
Object.wait, notify, and notifyAll , 1
ObjectArrayTest example , 1
objects
See also instances1
layout , 1
one-to-one mapping , 1
advantages and disadvantages , 1
vs. shared stubs , 1
OOPSLA , 1
opaque references , 1
OutOfMemoryError , 1

P

PATH , 1, 2
peer classes , 1
backpointers , 1
synchronized free method , 1
performance of JNI operations
accessing primitive arrays , 1
efficiency goal , 1
field access , 1
method call , 1
pinning , 1, 2
PopLocalFrame , 1, 2
porting layer , 1
primitive arrays , 1
primitive types , 1
printf , 1
private access control , 1
process separation , 1
programmer errors , 1
Prompt example , 1, 2, 3
PushLocalFrame , 1, 2

R

race condition
in caching field and method IDs , 1
in freeing native peers , 1
reference types , 1
references
comparing , 1
freeing , 1
global
See global references1
local
See local references1
opaque , 1, 2
rules for managing , 1
weak global
See weak global references1
reflection , 1, 2
RegisterNatives , 1, 2, 3
uses of , 1
registry of local references , 1
Release<Type>ArrayElements , 1, 2, 3
ReleaseBooleanArrayElements , 1
ReleaseByteArrayElements , 1
ReleaseCharArrayElements , 1
ReleaseDoubleArrayElements , 1
ReleaseFloatArrayElements , 1
ReleaseIntArrayElements , 1, 2, 3
ReleaseLongArrayElements , 1
ReleasePrimitiveArrayCritical , 1, 2, 3, 4
ReleaseShortArrayElements , 1
ReleaseStringChars , 1, 2, 3, 4
ReleaseStringCritical , 1, 2, 3
ReleaseStringUTFChars , 1, 2, 3
resolving field and method IDs , 1
restrictions
See also constraints1
on GetPrimitiveArrayCritical , 1, 2, 3
on GetStringCritical , 1, 2
Ritchie, Dennis , 1

S

SECURITY_ATTRIBUTES , 1
Set<Type>ArrayRegion , 1, 2
Set<Type>Field , 1
SetBooleanArrayRegion , 1
SetBooleanField , 1
SetByteArrayRegion , 1
SetByteField , 1
SetCharArrayRegion , 1
SetCharField , 1
SetDoubleArrayRegion , 1
SetDoubleField , 1
SetFloatArrayRegion , 1
SetFloatField , 1, 2
SetIntArrayRegion , 1, 2
SetIntField , 1
setjmp , 1
SetLongArrayRegion , 1
SetLongField , 1
SetObjectArrayElement , 1, 2
SetObjectField , 1, 2
SetShortArrayRegion , 1
SetShortField , 1
SetStatic<Type>Field , 1
SetStaticBooleanField , 1
SetStaticByteField , 1
SetStaticCharField , 1
SetStaticDoubleField , 1
SetStaticFloatField , 1
SetStaticIntField , 1, 2
SetStaticLongField , 1
SetStaticObjectField , 1
SetStaticShortField , 1
SetStringRegion , 1
SetStringUTFRegion , 1
sh , 1
shared library
See native library1
shared stubs , 1
advantages and disadvantages , 1
implementation , 1
vs. one-to-one mapping , 1
short , 1
Smalltalk , 1
socket descriptors , 1
Solaris
native threads , 1
shared library , 1
Solaris C compiler , 1
standard shell , 1
static fields , 1
accessing , 1
static initializer , 1
invoked by
FindClass , 1
GetFieldID , 1
GetMethodID , 1
GetStaticFieldID , 1
GetStaticMethodID , 1
static methods , 1
native , 1
steps in calling , 1
StaticFieldAccess example , 1
StaticMethodCall example , 1
stdcall , 1, 2
stderr , 1
stdio.h header file , 1
String , 1
See also strings1
String constructor , 1
String.getBytes method , 1
StringIndexOutOfBoundsException , 1, 2, 3
strings , 1
accessing , 1
ASCII , 1
choosing among functions , 1
constructing , 1
freeing resources , 1
NULL-terminated C , 1
summary of functions , 1
Unicode , 1
UTF-8 , 1, 2
Stroustrup, Bjarne , 1
stub functions , 1
subtyping , 1, 2
synchronization
in peer classes , 1
synchronized blocks , 1
System.loadLibrary , 1, 2
how to use , 1
System.mapLibraryName , 1
System.out.err , 1
System.runFinalization , 1

T

tcsh , 1
"this" pointer in C++ , 1
thr_create , 1
thread models , 1, 2
See also Green, native, and user thread models1
Thread.start , 1
Thread.stop , 1
threads , 1
constraints on programming , 1
thread-local JNIEnv , 1
validity of local references , 1
Throw , 1, 2
ThrowNew , 1, 2, 3
ToReflectedField , 1, 2
ToReflectedMethod , 1, 2
type conversion
in C++ , 1

U

Unicode strings , 1
not NULL-terminated , 1
UNIX , 1
UnregisterNatives , 1
UnsatisfiedLinkError , 1, 2, 3
user thread model , 1
UTF-8 strings , 1, 2
utility functions , 1
JNU_CallMethodByName , 1
JNU_FindCreateJavaVM , 1
JNU_GetEnv , 1
JNU_GetStringNativeChars , 1
JNU_MonitorNotify , 1
JNU_MonitorNotifyAll , 1
JNU_MonitorWait , 1
JNU_NewStringNative , 1
JNU_ThrowByName , 1

V

-verbose
gc, class, jni , 1
-verbose:jni option , 1, 2
vfprintf hook , 1, 2
virtual machine instances , 1

W

weak global references , 1, 2
in native peers , 1
uses of IsSameObject , 1
Win32
CreateFile API , 1
dynamic link library , 1
Win32.CreateFile example , 1, 2
wrapper classes , 1

X

-Xcheck:jni option , 1, 2
-Xmx option , 1

Contents | Prev | Next | Index The Java Native Interface
Programmer's Guide and Specification

Copyright © 2002 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to jni@java.sun.com