Book description
The Java Native Interface (JNI) enables the integration of code written in the Java programming language with code written in other languages such as C and C++. It allows programmers to take full advantage of the Java platform without having to abandon their investment in legacy code.
This book is the definitive resource and a comprehensive guide to working with the JNI. Entirely up-to-date, the book offers a tutorial, a detailed description of JNI features and programming techniques, JNI design justifications, and the official specification for all JNI types and functions.
You will find coverage of important topics such as:
Writing native methods
Passing data types between the Java language and native programming languages
Embedding a Java virtual machine implementation in native applications
Leveraging legacy native libraries
Improving the efficiency and reliability of your code
An entire chapter is devoted to avoiding common traps and pitfalls. The book uses numerous examples to illustrate programming techniques that have proven to be effective.
0201325772B04062001
Table of contents
- Copyright
- Preface
- I. Introduction and Tutorial
-
II. Programmer’s Guide
- 3. Basic Types, Strings, and Arrays
- 4. Fields and Methods
- 5. Local and Global References
- 6. Exceptions
- 7. The Invocation Interface
- 8. Additional JNI Features
- 9. Leveraging Existing Native Libraries
-
10. Traps and Pitfalls
- 10.1. Error Checking
- 10.2. Passing Invalid Arguments to JNI Functions
- 10.3. Confusing jclass with jobject
- 10.4. Truncating jboolean Arguments
- 10.5. Boundaries between Java Application and Native Code
- 10.6. Confusing IDs with References
- 10.7. Caching Field and Method IDs
- 10.8. Terminating Unicode Strings
- 10.9. Violating Access Control Rules
- 10.10. Disregarding Internationalization
- 10.11. Retaining Virtual Machine Resources
- 10.12. Excessive Local Reference Creation
- 10.13. Using Invalid Local References
- 10.14. Using the JNIEnv across Threads
- 10.15. Mismatched Thread Models
-
III. Specification
- 11. Overview of the JNI Design
- 12. JNI Types
-
13. JNI Functions
-
13.1. Summary of the JNI Functions
- 13.1.1. Directly-Exported Invocation Interface Functions
- 13.1.2. The JavaVM Interface
- 13.1.3. Functions Defined in Native Libraries
- 13.1.4. The JNIEnv Interface
- Version Information
- Class and Interface Operations
- Exceptions
- Global and Local References
- Object Operations
- Instance Field Access
- Static Field Access
- Instance Method Calls
- Static Method Calls
- String Operations
- Array Operations
- Native Method Registration
- Monitor Operations
- JavaVM Interface
- Reflection Support
-
13.2. Specification of JNI Functions
- AllocObject
- AttachCurrentThread
- Call<Type>Method
- Call<Type>MethodA
- Call<Type>MethodV
- CallNonvirtual<Type>Method
- CallNonvirtual<Type>MethodA
- CallNonvirtual<Type>MethodV
- CallStatic<Type>Method
- CallStatic<Type>MethodA
- CallStatic<Type>MethodV
- DefineClass
- DeleteGlobalRef
- DeleteLocalRef
- DeleteWeakGlobalRef
- DestroyJavaVM
- DetachCurrentThread
- EnsureLocalCapacity
- ExceptionCheck
- ExceptionClear
- ExceptionDescribe
- ExceptionOccurred
- FatalError
- FindClass
- FromReflectedField
- FromReflectedMethod
- GetArrayLength
- Get<Type>ArrayElements
- Get<Type>ArrayRegion
- Get<Type>Field
- GetEnv
- GetFieldID
- GetJavaVM
- GetMethodID
- GetObjectArrayElement
- GetObjectClass
- GetPrimitiveArrayCritical
- GetStaticFieldID
- GetStatic<Type>Field
- GetStaticMethodID
- GetStringChars
- GetStringCritical
- GetStringLength
- GetStringRegion
- GetStringUTFChars
- GetStringUTFLength
- GetStringUTFRegion
- GetSuperclass
- GetVersion
- IsAssignableFrom
- IsInstanceOf
- IsSameObject
- JNI_CreateJavaVM
- JNI_GetCreatedJavaVMs
- JNI_GetDefaultJavaVMInitArgs
- JNI_OnLoad
- JNI_OnUnload
- MonitorEnter
- MonitorExit
- NewGlobalRef
- NewLocalRef
- NewObject
- NewObjectA
- NewObjectV
- NewObjectArray
- New<Type>Array
- NewString
- NewStringUTF
- NewWeakGlobalRef
- PopLocalFrame
- PushLocalFrame
- RegisterNatives
- Release<Type>ArrayElements
- ReleasePrimitiveArrayCritical
- ReleaseStringChars
- ReleaseStringCritical
- ReleaseStringUTFChars
- Set<Type>ArrayRegion
- Set<Type>Field
- SetObjectArrayElement
- SetStatic<Type>Field
- Throw
- ThrowNew
- ToReflectedField
- ToReflectedMethod
- UnregisterNatives
-
13.1. Summary of the JNI Functions
Product information
- Title: Java™ Native Interface: Programmer’s Guide and Specification, The
- Author(s):
- Release date: June 1999
- Publisher(s): Addison-Wesley Professional
- ISBN: 0201325772
You might also like
book
C# Graphics Programming
This Wrox Blox teaches you how to add graphics to C# 2008 applications, explaining fundamental graphics …
book
OpenGL Programming for Windows 95 and Windows NT
The licensing of OpenGL to many leading computer companies, including Microsoft, has made it possible for …
book
Android Application Development for the Intel® Platform
The number of Android devices running on Intel processors has increased since Intel and Google announced, …
book
Developing Games in Java™
If you already have Java programming experience and are looking to program games, this book is …