jni 文档

本文详细介绍了Java Native Interface (JNI) 的设计原则、类型与数据结构、函数使用等核心内容,并提供了加载和链接本地方法、处理Java对象及异常的具体方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载: http://docs.oracle.com/javase/1.4.2/docs/guide/jni/spec/jniTOC.html

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

NewObject NewObjectA NewObjectV

GetObjectClass

IsInstanceOf

IsSameObject

Accessing Fields of Objects

GetFieldID

Get<type>Field Routines

Set<type>Field Routines

Calling Instance Methods

GetMethodID

Call<type>Method Routines Call<type>MethodA Routines Call<type>MethodV Routines

CallNonvirtual<type>Method Routines CallNonvirtual<type>MethodA Routines CallNonvirtual<type>MethodV Routines

Accessing Static Fields

GetStaticFieldID

GetStatic<type>Field Routines

SetStatic<type>Field Routines

Calling Static Methods

GetStaticMethodID

CallStatic<type>Method Routines CallStatic<type>MethodA Routines CallStatic<type>MethodV Routines

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

 


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值