Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
4 Cards in this Set
- Front
- Back
What is JNI? Where is it useful?
|
JNI is a mechanism to invoke native methods typically written in C++ from inside a JVM.
|
|
What are the strengths and weaknesses of using JNI?
|
JNI can be used to boost performance. It gets used when we want to do something close to hardware like manipulating a framebuffer in a graphics application. The down-side of JNI is that the code is not portable. It is tied to the hardware platform to which the native code is built for.
|
|
Outline the steps involved in writing a JNI module.
|
Declare a method in a class using the native keyword. Load the library that implements the native method using a static initializer block. Generate the native header file using the javah utility. Implement the native method using the same signature generated by the header file. Compile the native module into a library and run the application.
|
|
Explain JNI methods and pointers.
|
Java generates the native method name by concatenating the following items. The prefix Java_, encoded fully qualified class name, underscore separator, encoded method name. Each native method gets a JNIEnv interface pointer. This gives the ability to get more information about the JVM from which the method is being invoked. Instances methods get a jobject parameter that represents the Java object on which the native method is invoked. For a static method a jclass parameter is present that represents the class.
|