Study your flashcards anywhere!

Download the official Cram app for free >

  • Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key

image

Play button

image

Play button

image

Progress

1/4

Click to flip

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.