JNI tutorial

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 MethodNative Method ArgumentsMapping of Types
3.2  Accessing Strings
Converting to Native StringsFreeing Native String ResourcesConstructing New StringsOther JNI String FunctionsNew JNI String Functions in Java 2 SDK Release 1.2Summary of JNI String FunctionsChoosing among the String Functions
3.3  Accessing Arrays
Accessing Arrays in CAccessing Arrays of Primitive TypesSummary of JNI Primitvie Array FunctionsChoosing among the Primitive Array FunctionsAcessing Arrays of Objects

4 Fields and Methods

4.1  Accessing Fields
Procedure for Accessing an Instance FieldField DescriptorsAccessing Static Fields
4.2  Calling Methods
Calling Instance MethodsForming the Method DescriptorCalling Static MethodsCalling Instance Methods of a Superclass
4.3  Invoking Constructors
4.4  Caching Field and Method IDs
Caching at the Point of UseCaching in the Defining Class's InitializerComparison 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 ReferencesGlobal ReferencesWeak Global ReferencesComparing References
5.2  Freeing References
Freeing Local ReferencesManaging Local References in Java 2 SDK Release 1.2Freeing Gloabl References
5.3  Rules for Managing References

6 Exceptions

6.1  Overview
Caching and Throwing Exceptions in Native CodeA Utility Function
6.2  Proper Exception Handling
Checking for ExceptionsHandling ExceptionsExceptions 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 MachineLinking with Unknown Java Virtual Machine
7.3   Attaching Native Threads

8 Additional JNI Features

8.1  JNI and Threads
ContraintsMonitor Entry and ExitMonitor Wait and NotifyObtaining a JNIEnv Pointer in Arbitrary ContextsMatching the Thread Models
8.2  Writing Internationalized Code
Creating jstrings from Native StringsTranslating jstrings to Native Strings
8.3  Registering Native Methods
8.4  Load and Unload Handlers
The JNI_OnLoad HandlerThe 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

發佈了14 篇原創文章 · 獲贊 3 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章