Chapter 5. Local and Global References

The JNI exposes instance and array types (such as jobject, jclass, jstring, and jarray) as opaque references. Native code never directly inspects the contents of an opaque reference pointer. Instead it uses JNI functions to access the data structure pointed to by an opaque reference. By only dealing with opaque references, you need not worry about internal object layout that is dependent upon a particular Java virtual machine implementation. You do, however, need to learn more about different kinds of references in the JNI:

  • The JNI supports three kinds of opaque references: local references, global references, and weak global references.

  • Local and global references have different lifetimes. Local references ...

Get Java™ Native Interface: Programmer’s Guide and Specification, The now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.