Clone this repo:
  1. 8a14367 Merge "Move tests in libnativehelper_test.cpp out of tests_mts." into main by Jiakai Zhang · 6 days ago main master
  2. 4c60397 Move tests in libnativehelper_test.cpp out of tests_mts. by Jiakai Zhang · 8 days ago
  3. f75aeea Merge "AFileDescriptor_setFd should invoke setInt$" into main am: e322933c80 by Treehugger Robot · 4 weeks ago
  4. e322933 Merge "AFileDescriptor_setFd should invoke setInt$" into main by Treehugger Robot · 4 weeks ago
  5. b779a29 AFileDescriptor_setFd should invoke setInt$ by Victor Chang · 5 weeks ago

libnativehelper

libnativehelper is a collection of JNI related utilities used in Android.

There are several header and binary libraries here and not all of the functionality fits together well. The header libraries are mostly C++ based. The binary libraries are entirely written in C with no C++ dependencies. This is by design as the code here can be distributed in multiple ways, including mainline modules, so keeping the size down benefits everyone with smaller downloads and a stable ABI.

Header Libraries

jni_headers

This is a header library that provides the API in the JNI Specification 1.6. Any project in Android that includes jni.h should depend on this.

See:

libnativehelper_header_only

Header library that provide utilities defined entirely within the headers. There are scoped resource classes that make common JNI patterns of acquiring and releasing resources safer to use than the JNI specification equivalents. Examples being ScopedLocalRef to manage the lifetime of local references and ScopedUtfChars to manage the lifetime of Java strings in native code and provide access to utf8 characters.

See:

jni_platform_headers

The jni_macros.h header provide compile time checking of JNI methods implemented in C++. They ensure the C++ method declaration match the Java signature they are associated with.

See:

Libraries

libnativehelper

A shared library distributed in the ART module. It provides the JNI invocation API from the JNI Specification, which is part of the public NDK. It also contains the glue that connects the API implementation to the ART runtime, which is platform only and is used with the Zygote and the standalone dalvikvm.

See:

libnativehelper_compat_libc++

This shared and static library contains a subset of the helper routines in libnativehelper based only on public stable JNI APIs. It gets distributed with the caller code and is preferrably linked statically since it is very thin (less than 20 KB). The name of this library is a misnomer since it contains no C++ code.

See: