Java Native Interface Specification

May 16, 1997


Contents


1. Introduction

Java Native Interface Overview

Background

JDK 1.0 Native Method Interface

Java Runtime Interface

Raw Native Interface and Java/COM Interface

Objectives

Java Native Interface Approach

Programming to the JNI

Changes in JDK 1.1.2

2. Design Overview

JNI Interface Functions and Pointers

Loading and Linking Native Methods

Resolving Native Method Names

Native Method Arguments

Referencing Java Objects

Global and Local References

Implementing Local References

Accessing Java Objects

Accessing Primitive Arrays

Accessing Fields and Methods

Reporting Programming Errors

Java Exceptions

Exceptions and Error Codes

Asynchronous Exceptions

Exception Handling

3. JNI Types and Data Structures

Primitive Types

Reference Types

Field and Method IDs

The Value Type

Type Signatures

UTF-8 Strings

4. JNI Functions

Interface Function Table

Version Information

GetVersion

Class Operations

DefineClass

FindClass

GetSuperclass

IsAssignableFrom

Exceptions

Throw

ThrowNew

ExceptionOccurred

ExceptionDescribe

ExceptionClear

FatalError

Global and Local References

NewGlobalRef

DeleteGlobalRef

DeleteLocalRef

Object Operations

AllocObject

GetObjectClass

IsInstanceOf

IsSameObject

Accessing Fields of Objects

GetFieldID

Get<type>Field Routines

Set<type>Field Routines

Calling Instance Methods

GetMethodID

Call<type>Method

CallNonvirtual<type>Method

Accessing Static Fields

GetStaticFieldID

GetStatic<type>Field Routines

SetStatic<type>Field Routines

Calling Static Methods

GetStaticMethodID

CallStatic<type>Method

String Operations

NewString

GetStringLength

GetStringChars

ReleaseStringChars

NewStringUTF

GetStringUTFLength

GetStringUTFChars

ReleaseStringUTFChars

Array Operations

GetArrayLength

NewObjectArray

GetObjectArrayElement

SetObjectArrayElement

New<PrimitiveType>Array Routines

Get<PrimitiveType>ArrayElements Routines

Release<PrimitiveType>ArrayElements Routines

Get<PrimitiveType>ArrayRegion Routines

Set<PrimitiveType>ArrayRegion Routines

Registering Native Methods

RegisterNatives

UnregisterNatives

Monitor Operations

MonitorEnter

MonitorExit

Java VM Interface

GetJavaVM

5. The Invocation API

Overview

Creating the VM

Attaching to the VM

Unloading the VM

Initialization Structures

Invocation API Functions

JNI_GetDefaultJavaVMInitArgs

JNI_GetCreatedJavaVMs

JNI_CreateJavaVM

DestroyJavaVM

AttachCurrentThread

DetachCurrentThread


Contents | Prev | Next

Java Native Interface Specification (HTML generated by dkramer on March 15, 1997)
All rights reserved
Please send any comments or corrections to jni@java.sun.com