xref: /aosp_15_r20/libnativehelper/README.md (revision 0797b24ee566c78eb48500180cb4bf71f81c8aab)
1*0797b24eSAndroid Build Coastguard Worker# libnativehelper
2*0797b24eSAndroid Build Coastguard Worker
3*0797b24eSAndroid Build Coastguard Workerlibnativehelper is a collection of JNI related utilities used in Android.
4*0797b24eSAndroid Build Coastguard Worker
5*0797b24eSAndroid Build Coastguard WorkerThere are several header and binary libraries here and not all of the
6*0797b24eSAndroid Build Coastguard Workerfunctionality fits together well. The header libraries are mostly C++
7*0797b24eSAndroid Build Coastguard Workerbased. The binary libraries are entirely written in C with no C++
8*0797b24eSAndroid Build Coastguard Workerdependencies. This is by design as the code here can be distributed in
9*0797b24eSAndroid Build Coastguard Workermultiple ways, including mainline modules, so keeping the size down
10*0797b24eSAndroid Build Coastguard Workerbenefits everyone with smaller downloads and a stable ABI.
11*0797b24eSAndroid Build Coastguard Worker
12*0797b24eSAndroid Build Coastguard Worker## Header Libraries
13*0797b24eSAndroid Build Coastguard Worker
14*0797b24eSAndroid Build Coastguard Worker### jni_headers
15*0797b24eSAndroid Build Coastguard Worker
16*0797b24eSAndroid Build Coastguard WorkerThis is a header library that provides the API in the JNI Specification 1.6.
17*0797b24eSAndroid Build Coastguard WorkerAny project in Android that includes `jni.h` should depend on this.
18*0797b24eSAndroid Build Coastguard Worker
19*0797b24eSAndroid Build Coastguard WorkerSee:
20*0797b24eSAndroid Build Coastguard Worker
21*0797b24eSAndroid Build Coastguard Worker* [jni.h](include_jni/jni.h)
22*0797b24eSAndroid Build Coastguard Worker
23*0797b24eSAndroid Build Coastguard Worker### libnativehelper_header_only
24*0797b24eSAndroid Build Coastguard Worker
25*0797b24eSAndroid Build Coastguard WorkerHeader library that provide utilities defined entirely within the headers. There
26*0797b24eSAndroid Build Coastguard Workerare scoped resource classes that make common JNI patterns of acquiring and
27*0797b24eSAndroid Build Coastguard Workerreleasing resources safer to use than the JNI specification equivalents.
28*0797b24eSAndroid Build Coastguard WorkerExamples being `ScopedLocalRef` to manage the lifetime of local references and
29*0797b24eSAndroid Build Coastguard Worker`ScopedUtfChars` to manage the lifetime of Java strings in native code and
30*0797b24eSAndroid Build Coastguard Workerprovide access to utf8 characters.
31*0797b24eSAndroid Build Coastguard Worker
32*0797b24eSAndroid Build Coastguard WorkerSee:
33*0797b24eSAndroid Build Coastguard Worker
34*0797b24eSAndroid Build Coastguard Worker* [nativehelper/nativehelper_utils.h](header_only_include/nativehelper/nativehelper_utils.h)
35*0797b24eSAndroid Build Coastguard Worker* [nativehelper/scoped_utf_chars.h](header_only_include/nativehelper/scoped_utf_chars.h)
36*0797b24eSAndroid Build Coastguard Worker* [nativehelper/scoped_string_chars.h](header_only_include/nativehelper/scoped_string_chars.h)
37*0797b24eSAndroid Build Coastguard Worker* [nativehelper/scoped_primitive_array.h](header_only_include/nativehelper/scoped_primitive_array.h)
38*0797b24eSAndroid Build Coastguard Worker* [nativehelper/scoped_local_ref.h](header_only_include/nativehelper/scoped_local_ref.h)
39*0797b24eSAndroid Build Coastguard Worker* [nativehelper/scoped_local_frame.h](header_only_include/nativehelper/scoped_local_frame.h)
40*0797b24eSAndroid Build Coastguard Worker* [nativehelper/utils.h](header_only_include/nativehelper/utils.h)
41*0797b24eSAndroid Build Coastguard Worker
42*0797b24eSAndroid Build Coastguard Worker### jni_platform_headers
43*0797b24eSAndroid Build Coastguard Worker
44*0797b24eSAndroid Build Coastguard WorkerThe `jni_macros.h` header provide compile time checking of JNI methods
45*0797b24eSAndroid Build Coastguard Workerimplemented in C++. They ensure the C++ method declaration match the
46*0797b24eSAndroid Build Coastguard WorkerJava signature they are associated with.
47*0797b24eSAndroid Build Coastguard Worker
48*0797b24eSAndroid Build Coastguard WorkerSee:
49*0797b24eSAndroid Build Coastguard Worker
50*0797b24eSAndroid Build Coastguard Worker* [nativehelper/jni_macros.h](include_platform_header_only/nativehelper/jni_macros.h)
51*0797b24eSAndroid Build Coastguard Worker
52*0797b24eSAndroid Build Coastguard Worker## Libraries
53*0797b24eSAndroid Build Coastguard Worker
54*0797b24eSAndroid Build Coastguard Worker### libnativehelper
55*0797b24eSAndroid Build Coastguard Worker
56*0797b24eSAndroid Build Coastguard WorkerA shared library distributed in the ART module. It provides the JNI invocation
57*0797b24eSAndroid Build Coastguard WorkerAPI from the JNI Specification, which is part of the public NDK. It also
58*0797b24eSAndroid Build Coastguard Workercontains the glue that connects the API implementation to the ART runtime, which
59*0797b24eSAndroid Build Coastguard Workeris platform only and is used with the Zygote and the standalone dalvikvm.
60*0797b24eSAndroid Build Coastguard Worker
61*0797b24eSAndroid Build Coastguard WorkerSee:
62*0797b24eSAndroid Build Coastguard Worker
63*0797b24eSAndroid Build Coastguard Worker* [nativehelper/JniInvocation.h](include_platform/nativehelper/JniInvocation.h)
64*0797b24eSAndroid Build Coastguard Worker* [nativehelper/JNIPlatformHelp.h](include_platform/nativehelper/JNIPlatformHelp.h)
65*0797b24eSAndroid Build Coastguard Worker* libnativehelper_compat_libc++ headers below
66*0797b24eSAndroid Build Coastguard Worker
67*0797b24eSAndroid Build Coastguard Worker### libnativehelper_compat_libc++
68*0797b24eSAndroid Build Coastguard Worker
69*0797b24eSAndroid Build Coastguard WorkerThis shared and static library contains a subset of the helper routines in
70*0797b24eSAndroid Build Coastguard Workerlibnativehelper based only on public stable JNI APIs. It gets distributed with
71*0797b24eSAndroid Build Coastguard Workerthe caller code and is preferrably linked statically since it is very thin (less
72*0797b24eSAndroid Build Coastguard Workerthan 20 KB). The name of this library is a misnomer since it contains no C++
73*0797b24eSAndroid Build Coastguard Workercode.
74*0797b24eSAndroid Build Coastguard Worker
75*0797b24eSAndroid Build Coastguard WorkerSee:
76*0797b24eSAndroid Build Coastguard Worker
77*0797b24eSAndroid Build Coastguard Worker* [nativehelper/JNIHelp.h](include/nativehelper/JNIHelp.h)
78*0797b24eSAndroid Build Coastguard Worker* [nativehelper/ScopedUtfChars.h](include/nativehelper/ScopedUtfChars.h)
79*0797b24eSAndroid Build Coastguard Worker* [nativehelper/ScopedLocalFrame.h](include/nativehelper/ScopedLocalFrame.h)
80*0797b24eSAndroid Build Coastguard Worker* [nativehelper/ScopedLocalRef.h](include/nativehelper/ScopedLocalRef.h)
81*0797b24eSAndroid Build Coastguard Worker* [nativehelper/ScopedPrimitiveArray.h](include/nativehelper/ScopedPrimitiveArray.h)
82*0797b24eSAndroid Build Coastguard Worker* [nativehelper/ScopedStringChars.h](include/nativehelper/ScopedStringChars.h)
83*0797b24eSAndroid Build Coastguard Worker* [nativehelper/toStringArray.h](include/nativehelper/toStringArray.h)
84*0797b24eSAndroid Build Coastguard Worker* [nativehelper/Utils.h](include/nativehelper/Utils.h)
85