Where Is JNI Used?

JNI is the official interface of Sun Microsystems that can be used to communicate between native and Java code. As mentioned earlier, many Java packages use native libraries. The idea is that once you have access to native code, you can do just about anything. If you search the JDK directory, you will find several binaries (such as .lib, .dll, or .so files) that are used by the Java libraries. For example, you may find awt.dll, jsound.dll, zip.dll, j3d.dll, or win32com.dll. These libraries correspond to abstract windowing toolkit (AWT), Java sound, Zip utilities, and comm port API, respectively. They contain native functions that are called from the Java side by their corresponding packages. If you view the function table of these libraries with tools such as Microsoft Dependency Viewer, you can get an idea of when their corresponding libraries rely on native code. Additionally, if you launch the VM with -verbose:jni, you can see some JNI activities. The following is only a segment of the output when running an empty Main method of an empty class:

Dynamic-linking/Registering native method: java.lang.StrictMath.pow  java.lang.Float.intBitsToFloat  java.lang.Object.registerNatives  java.lang.System.registerNatives  java.lang.Object.has java.lang.Object.clone java.lang.System.currentTimeMillis java.lang.System.arraycopy java.lang.Thread.yield java.lang.Thread.sleep java.lang.ClassLoader.retrieveDirectives java.lang.Class.getName java.lang.Class.getSuperclass java.lang.Class.isArray sun.misc.Unsafe.getObject java.lang.Compiler.compileClass java.io.FileSystem.getFileSystem java.io.FileInputStream.open  java.io.FileInputStream.readBytes  java.lang.String.intern  java.util.zip.ZipFile.open  java.util.zip.ZipFile.getEntry



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net