JNI tutorial

本文详细介绍了Java平台与主机环境之间的交互机制,包括如何使用JNI(Java Native Interface),从基本类型、字符串和数组到字段、方法的访问,再到本地和全局引用的管理以及异常处理,最终涵盖了额外的JNI特性。

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

http://java.sun.com/docs/books/jni/html/jniTOC.html


Part One: Introduction and Tutorial

1 Introduction

1.1 The Java Platform and Host Environment
1.2  Role of the JNI
1.3  Implications of Using the JNI
1.4  When to Use the JNI
1.5  Evolution of the JNI
1.6  Example Programs

2 Getting Started

2.1  Overview
2.2  Declare the Native Method
2.3  Compile the HelloWorld Class
2.4  Create the Native Method Header File
2.5  Write the Native Method Implementation
2.6  Compile the C Source and Create a Native Library
2.7  Run the Program

Part Two: Programmer's Guide

3 Basic Types, Strings, and Arrays

3.1  A Simple Native Method
C Prototype for Implementing the Native Method Native Method Arguments Mapping of Types
3.2  Accessing Strings
Converting to Native Strings Freeing Native String Resources Constructing New Strings Other JNI String Functions New JNI String Functions in Java 2 SDK Release 1.2 Summary of JNI String Functions Choosing among the String Functions
3.3  Accessing Arrays
Accessing Arrays in C Accessing Arrays of Primitive Types Summary of JNI Primitvie Array Functions Choosing among the Primitive Array Functions Acessing Arrays of Objects

4 Fields and Methods

4.1  Accessing Fields
Procedure for Accessing an Instance Field Field Descriptors Accessing Static Fields
4.2  Calling Methods
Calling Instance Methods Forming the Method Descriptor Calling Static Methods Calling Instance Methods of a Superclass
4.3  Invoking Constructors
4.4  Caching Field and Method IDs
Caching at the Point of Use Caching in the Defining Class's Initializer Comparison between the Two Approaches to Caching IDs
4.5  Performance of JNI Field and Method Operations

5 Local and Global References

5.1  Local and Global References
Local References Global References Weak Global References Comparing References
5.2  Freeing References
Freeing Local References Managing Local References in Java 2 SDK Release 1.2 Freeing Gloabl References
5.3  Rules for Managing References

6 Exceptions

6.1  Overview
Caching and Throwing Exceptions in Native Code A Utility Function
6.2  Proper Exception Handling
Checking for Exceptions Handling Exceptions Exceptions in Utility Functions

7 The Invocation Interface

7.1  Creating the Java Virtual Machine
7.2  Linking Native Applications with the Java Virtual Machine
Linking with a Known Java Virtual Machine Linking with Unknown Java Virtual Machine
7.3   Attaching Native Threads

8 Additional JNI Features

8.1  JNI and Threads
Contraints Monitor Entry and Exit Monitor Wait and Notify Obtaining a JNIEnv Pointer in Arbitrary Contexts Matching the Thread Models
8.2  Writing Internationalized Code
Creating jstrings from Native Strings Translating jstrings to Native Strings
8.3  Registering Native Methods
8.4  Load and Unload Handlers
The JNI_OnLoad Handler The JNI_OnUnload Handler
8.5  Reflection Support
8.6  JNI Programming in C++

9 Leveraging Existing Native Libraries

9.1  One-to-One Mapping
9.2  Shared Stubs
9.3  One-to-One Mapping versus Shared Stubs
9.4  Implementation of Shared Stubs

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值