Java Native Interface Specification—Contents

时间:2024-04-27 12:08:40

http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/jniTOC.html

1. Introduction

Java Native Interface OverviewBackground

JDK 1.0 Native Method InterfaceJava Runtime Interface
Raw Native Interface and Java/COM Interface

ObjectivesJava Native Interface Approach
Programming to the JNIChanges in JDK 1.1.2

2. Design Overview

JNI Interface Functions and PointersCompiling, Loading and Linking Native Methods

Resolving Native Method NamesNative Method Arguments

Referencing Java Objects

Global and Local ReferencesImplementing Local References

Accessing Java Objects

Accessing Primitive ArraysAccessing Fields and Methods

Reporting Programming ErrorsJava Exceptions

Exceptions and Error CodesAsynchronous ExceptionsException Handling

3. JNI Types and Data Structures

Primitive Types
Reference Types
Field and Method IDs
The Value Type
Type Signatures
Modified UTF-8 Strings

4. JNI Functions

Interface Function Table
Version Information

GetVersion

Class Operations

DefineClassFindClassGetSuperclassIsAssignableFrom

Exceptions

ThrowThrowNew
ExceptionOccurredExceptionDescribe
ExceptionClearFatalErrorExceptionCheck

Global and Local References

NewGlobalRefDeleteGlobalRef
DeleteLocalRefEnsureLocalCapacityPushLocalFramePopLocalFrameNewLocalRef

Weak Global References

NewWeakGlobalRefDeleteWeakGlobalRef

Object Operations

AllocObjectNewObject, NewObjectA, and NewObjectV
GetObjectClass
GetObjectRefType
IsInstanceOf
IsSameObject

Accessing Fields of Objects

GetFieldIDGet<type>Field Routines
Set<type>Field Routines

Calling Instance Methods

GetMethodIDCall<type>Method Routines, Call<type>MethodA Routines, and Call<type>MethodV Routines
CallNonvirtual<type>Method Routines, CallNonvirtual<type>MethodA Routines, and CallNonvirtual<type>MethodV Routines

Accessing Static Fields

GetStaticFieldIDGetStatic<type>Field Routines
SetStatic<type>Field Routines

Calling Static Methods

GetStaticMethodIDCallStatic<type>Method Routines, CallStatic<type>MethodA Routines, and CallStatic<type>MethodV Routines

String Operations

NewStringGetStringLength
GetStringCharsReleaseStringChars
NewStringUTFGetStringUTFLength
GetStringUTFCharsReleaseStringUTFCharsGetStringRegionGetStringUTFRegionGetStringCriticalRelease StringCritical

Array Operations

GetArrayLengthNewObjectArray
GetObjectArrayElementSetObjectArrayElement
New<PrimitiveType>Array RoutinesGet<PrimitiveType>ArrayElements Routines
Release<PrimitiveType>ArrayElements RoutinesGet<PrimitiveType>ArrayRegion Routines
Set<PrimitiveType>ArrayRegion RoutinesGetPrimitiveArrayCriticalReleasePrimitiveArrayCritical

Registering Native Methods

RegisterNativesUnregisterNatives

Monitor Operations

MonitorEnterMonitorExit

NIO Support

NewDirectByteBufferGetDirectBufferAddressGetDirectBufferCapacity

Reflection Support

FromReflectedMethodFromReflectedFieldToReflectedMethodToReflectedField

Java VM Interface

GetJavaVM

5. The Invocation API

Overview

Creating the VMAttaching to the VM
Unloading the VM

Library and Version Management

JNI_OnLoadJNI_OnUnload

Invocation API Functions

JNI_GetDefaultJavaVMInitArgsJNI_GetCreatedJavaVMs
JNI_CreateJavaVMDestroyJavaVM
AttachCurrentThreadAttachCurrentThreadAsDaemonDetachCurrentThreadGetEnv