1# libnativehelper 2 3libnativehelper is a collection of JNI related utilities used in Android. 4 5There are several header and binary libraries here and not all of the 6functionality fits together well. The header libraries are mostly C++ 7based. The binary libraries are entirely written in C with no C++ 8dependencies. This is by design as the code here can be distributed in 9multiple ways, including mainline modules, so keeping the size down 10benefits everyone with smaller downloads and a stable ABI. 11 12## Header Libraries 13 14### jni_headers 15 16This is a header library that contains provides the API represented in 17the JNI Specification 1.6. Any project in Android that depends on 18`jni.h` should depend on this. 19 20See: 21 22* [jni.h](include_jni/jni.h) 23 24### libnativehelper_header_only 25 26These headers provide utilities that defined entirely within the 27headers. There are scoped resource classes that make common JNI 28patterns of acquiring and releasing resources safer to use than the 29JNI specification equivalents. Examples being `ScopedLocalRef` to 30manage the lifetime of local references and `ScopedUtfChars` to manage 31the lifetime of Java strings in native code and provide access to utf8 32characters. 33 34See: 35 36* [nativehelper/nativehelper_utils.h](header_only_include/nativehelper/nativehelper_utils.h) 37* [nativehelper/scoped_utf_chars.h](header_only_include/nativehelper/scoped_utf_chars.h) 38* [nativehelper/scoped_bytes.h](header_only_include/nativehelper/scoped_bytes.h) 39* [nativehelper/scoped_string_chars.h](header_only_include/nativehelper/scoped_string_chars.h) 40* [nativehelper/scoped_primitive_array.h](header_only_include/nativehelper/scoped_primitive_array.h) 41* [nativehelper/scoped_local_ref.h](header_only_include/nativehelper/scoped_local_ref.h) 42* [nativehelper/scoped_local_frame.h](header_only_include/nativehelper/scoped_local_frame.h) 43 44### jni_platform_headers 45 46The `jni_macros.h` header provide compile time checking of JNI methods 47implemented in C++. They ensure the C++ method declaration match the 48Java signature they are associated with. 49 50See: 51 52* [nativehelper/jni_macros.h](include_platform_header_only/nativehelper/jni_macros.h) 53 54## Libraries 55 56### libnativehelper 57 58A shared library distributed in the ART module that provides helper 59routines built on Java APIs. This library depends on details that are 60private to libcore and use should be restricted to platform code and 61within the ART module. 62 63This library also contains the JNI invocation API from the JNI 64Specification and the glue that connects the ART runtime to the API 65implementation. The glue logic is platform only as it is used with the 66Zygote and the standalone dalvikvm. 67 68See: 69* [nativehelper/JNIHelp.h](include/nativehelper/JNIHelp.h) 70* [nativehelper/JniInvocation.h](include_platform/nativehelper/JniInvocation.h) 71* [nativehelper/JNIPlatformHelp.h](include_platform/nativehelper/JNIPlatformHelp.h) 72* [nativehelper/ScopedBytes.h](include/nativehelper/ScopedBytes.h) 73* [nativehelper/ScopedUtfChars.h](include/nativehelper/ScopedUtfChars.h) 74* [nativehelper/ScopedLocalFrame.h](include/nativehelper/ScopedLocalFrame.h) 75* [nativehelper/ScopedLocalRef.h](include/nativehelper/ScopedLocalRef.h) 76* [nativehelper/ScopedPrimitiveArray.h](include/nativehelper/ScopedPrimitiveArray.h) 77* [nativehelper/ScopedStringChars.h](include/nativehelper/ScopedStringChars.h) 78* [nativehelper/toStringArray.h](include/nativehelper/toStringArray.h) 79 80### libnativehelper_compat_libc++ 81 82This shared and static library contains a subset of the helper 83routines in libnativehelper based on public Java API. This code can be 84statically linked as the Java APIs it depends on are considered 85stable. The name of this library is a misnomer since it contains no 86C++ code. 87 88See: 89 90* [nativehelper/JNIHelp.h](include/nativehelper/JNIHelp.h) 91* [nativehelper/ScopedBytes.h](include/nativehelper/ScopedBytes.h) 92* [nativehelper/ScopedUtfChars.h](include/nativehelper/ScopedUtfChars.h) 93* [nativehelper/ScopedLocalFrame.h](include/nativehelper/ScopedLocalFrame.h) 94* [nativehelper/ScopedLocalRef.h](include/nativehelper/ScopedLocalRef.h) 95* [nativehelper/ScopedPrimitiveArray.h](include/nativehelper/ScopedPrimitiveArray.h) 96* [nativehelper/ScopedStringChars.h](include/nativehelper/ScopedStringChars.h) 97* [nativehelper/toStringArray.h](include/nativehelper/toStringArray.h) 98