blob: e9c95002525d2f28b0978d565bde4e39a3c95926 [file] [log] [blame]
Calin Juravle961ae122014-08-11 16:11:59 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NATIVE_BRIDGE_H_
18#define NATIVE_BRIDGE_H_
19
Andreas Gampea6ac9ce2015-04-30 20:39:12 -070020#include <signal.h>
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +000021#include <stdbool.h>
Calin Juravle961ae122014-08-11 16:11:59 +010022#include <stdint.h>
jgu21ab0da5a2014-09-10 06:58:32 -040023#include <sys/types.h>
Calin Juravle961ae122014-08-11 16:11:59 +010024
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +000025#include "jni.h"
26
27#ifdef __cplusplus
Calin Juravle961ae122014-08-11 16:11:59 +010028namespace android {
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +000029extern "C" {
30#endif // __cplusplus
Calin Juravle961ae122014-08-11 16:11:59 +010031
32struct NativeBridgeRuntimeCallbacks;
jgu21ab0da5a2014-09-10 06:58:32 -040033struct NativeBridgeRuntimeValues;
Calin Juravle961ae122014-08-11 16:11:59 +010034
Andreas Gampea6ac9ce2015-04-30 20:39:12 -070035// Function pointer type for sigaction. This is mostly the signature of a signal handler, except
36// for the return type. The runtime needs to know whether the signal was handled or should be given
37// to the chain.
38typedef bool (*NativeBridgeSignalHandlerFn)(int, siginfo_t*, void*);
39
Andreas Gampe035bd752014-09-02 21:17:03 -070040// Open the native bridge, if any. Should be called by Runtime::Init(). A null library filename
41// signals that we do not want to load a native bridge.
42bool LoadNativeBridge(const char* native_bridge_library_filename,
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +000043 const struct NativeBridgeRuntimeCallbacks* runtime_callbacks);
Andreas Gampe035bd752014-09-02 21:17:03 -070044
jgu21ab0da5a2014-09-10 06:58:32 -040045// Quick check whether a native bridge will be needed. This is based off of the instruction set
46// of the process.
47bool NeedsNativeBridge(const char* instruction_set);
48
49// Do the early initialization part of the native bridge, if necessary. This should be done under
50// high privileges.
Calin Juravlef9d9e2a2014-10-17 13:45:39 +010051bool PreInitializeNativeBridge(const char* app_data_dir, const char* instruction_set);
jgu21ab0da5a2014-09-10 06:58:32 -040052
53// Initialize the native bridge, if any. Should be called by Runtime::DidForkFromZygote. The JNIEnv*
54// will be used to modify the app environment for the bridge.
55bool InitializeNativeBridge(JNIEnv* env, const char* instruction_set);
Andreas Gampe035bd752014-09-02 21:17:03 -070056
57// Unload the native bridge, if any. Should be called by Runtime::DidForkFromZygote.
58void UnloadNativeBridge();
59
60// Check whether a native bridge is available (opened or initialized). Requires a prior call to
61// LoadNativeBridge.
62bool NativeBridgeAvailable();
Calin Juravle961ae122014-08-11 16:11:59 +010063
Andreas Gampe049249c2014-08-19 22:31:31 -070064// Check whether a native bridge is available (initialized). Requires a prior call to
Andreas Gampe035bd752014-09-02 21:17:03 -070065// LoadNativeBridge & InitializeNativeBridge.
66bool NativeBridgeInitialized();
Andreas Gampe049249c2014-08-19 22:31:31 -070067
Calin Juravle961ae122014-08-11 16:11:59 +010068// Load a shared library that is supported by the native bridge.
Zhenhua WANGf2804e52016-05-30 11:16:08 +080069//
70// Starting with v3, NativeBridge has two scenarios: with/without namespace.
71// Use NativeBridgeLoadLibraryExt() instead in namespace scenario.
Calin Juravle961ae122014-08-11 16:11:59 +010072void* NativeBridgeLoadLibrary(const char* libpath, int flag);
73
74// Get a native bridge trampoline for specified native method.
75void* NativeBridgeGetTrampoline(void* handle, const char* name, const char* shorty, uint32_t len);
76
Zhenhua WANGf2804e52016-05-30 11:16:08 +080077// True if native library paths are valid and is for an ABI that is supported by native bridge.
78// The *libpath* must point to a library.
79//
80// Starting with v3, NativeBridge has two scenarios: with/without namespace.
81// Use NativeBridgeIsPathSupported() instead in namespace scenario.
Calin Juravle961ae122014-08-11 16:11:59 +010082bool NativeBridgeIsSupported(const char* libpath);
83
Andreas Gampea6ac9ce2015-04-30 20:39:12 -070084// Returns the version number of the native bridge. This information is available after a
85// successful LoadNativeBridge() and before closing it, that is, as long as NativeBridgeAvailable()
86// returns true. Returns 0 otherwise.
87uint32_t NativeBridgeGetVersion();
88
89// Returns a signal handler that the bridge would like to be managed. Only valid for a native
90// bridge supporting the version 2 interface. Will return null if the bridge does not support
91// version 2, or if it doesn't have a signal handler it wants to be known.
92NativeBridgeSignalHandlerFn NativeBridgeGetSignalHandler(int signal);
93
Andreas Gampe049249c2014-08-19 22:31:31 -070094// Returns whether we have seen a native bridge error. This could happen because the library
95// was not found, rejected, could not be initialized and so on.
96//
97// This functionality is mainly for testing.
98bool NativeBridgeError();
99
100// Returns whether a given string is acceptable as a native bridge library filename.
101//
102// This functionality is exposed mainly for testing.
103bool NativeBridgeNameAcceptable(const char* native_bridge_library_filename);
104
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800105// Decrements the reference count on the dynamic library handler. If the reference count drops
dimitry3150f7c2018-09-12 01:09:19 +0200106// to zero then the dynamic library is unloaded. Returns 0 on success and non-zero on error.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800107int NativeBridgeUnloadLibrary(void* handle);
108
109// Get last error message of native bridge when fail to load library or search symbol.
110// This is reflection of dlerror() for native bridge.
Dimitry Ivanovd836ab02016-11-02 18:03:10 -0700111const char* NativeBridgeGetError();
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800112
113struct native_bridge_namespace_t;
114
115// True if native library paths are valid and is for an ABI that is supported by native bridge.
116// Different from NativeBridgeIsSupported(), the *path* here must be a directory containing
117// libraries of an ABI.
118//
119// Starting with v3, NativeBridge has two scenarios: with/without namespace.
120// Use NativeBridgeIsSupported() instead in non-namespace scenario.
121bool NativeBridgeIsPathSupported(const char* path);
122
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800123// Initializes anonymous namespace.
124// NativeBridge's peer of android_init_anonymous_namespace() of dynamic linker.
125//
126// The anonymous namespace is used in the case when a NativeBridge implementation
127// cannot identify the caller of dlopen/dlsym which happens for the code not loaded
128// by dynamic linker; for example calls from the mono-compiled code.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800129//
130// Starting with v3, NativeBridge has two scenarios: with/without namespace.
131// Should not use in non-namespace scenario.
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800132bool NativeBridgeInitAnonymousNamespace(const char* public_ns_sonames,
133 const char* anon_ns_library_path);
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800134
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800135// Create new namespace in which native libraries will be loaded.
136// NativeBridge's peer of android_create_namespace() of dynamic linker.
137//
138// The libraries in the namespace are searched by folowing order:
139// 1. ld_library_path (Think of this as namespace-local LD_LIBRARY_PATH)
140// 2. In directories specified by DT_RUNPATH of the "needed by" binary.
141// 3. deault_library_path (This of this as namespace-local default library path)
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800142//
143// Starting with v3, NativeBridge has two scenarios: with/without namespace.
144// Should not use in non-namespace scenario.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000145struct native_bridge_namespace_t* NativeBridgeCreateNamespace(
146 const char* name, const char* ld_library_path, const char* default_library_path, uint64_t type,
147 const char* permitted_when_isolated_path, struct native_bridge_namespace_t* parent_ns);
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800148
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800149// Creates a link which shares some libraries from one namespace to another.
150// NativeBridge's peer of android_link_namespaces() of dynamic linker.
151//
152// Starting with v3, NativeBridge has two scenarios: with/without namespace.
153// Should not use in non-namespace scenario.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000154bool NativeBridgeLinkNamespaces(struct native_bridge_namespace_t* from,
155 struct native_bridge_namespace_t* to,
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800156 const char* shared_libs_sonames);
157
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800158// Load a shared library with namespace key that is supported by the native bridge.
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800159// NativeBridge's peer of android_dlopen_ext() of dynamic linker, only supports namespace
160// extension.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800161//
162// Starting with v3, NativeBridge has two scenarios: with/without namespace.
163// Use NativeBridgeLoadLibrary() instead in non-namespace scenario.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000164void* NativeBridgeLoadLibraryExt(const char* libpath, int flag,
165 struct native_bridge_namespace_t* ns);
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800166
dimitryd2ace382019-02-04 15:06:43 +0100167// Returns exported namespace by the name. This is a reflection of
168// android_get_exported_namespace function. Introduced in v5.
169struct native_bridge_namespace_t* NativeBridgeGetExportedNamespace(const char* name);
Dimitry Ivanov882cad22017-05-01 15:12:49 -0700170
Calin Juravle961ae122014-08-11 16:11:59 +0100171// Native bridge interfaces to runtime.
172struct NativeBridgeCallbacks {
jgu21ab0da5a2014-09-10 06:58:32 -0400173 // Version number of the interface.
174 uint32_t version;
175
Calin Juravle961ae122014-08-11 16:11:59 +0100176 // Initialize native bridge. Native bridge's internal implementation must ensure MT safety and
177 // that the native bridge is initialized only once. Thus it is OK to call this interface for an
178 // already initialized native bridge.
179 //
180 // Parameters:
181 // runtime_cbs [IN] the pointer to NativeBridgeRuntimeCallbacks.
182 // Returns:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800183 // true if initialization was successful.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000184 bool (*initialize)(const struct NativeBridgeRuntimeCallbacks* runtime_cbs,
185 const char* private_dir, const char* instruction_set);
Calin Juravle961ae122014-08-11 16:11:59 +0100186
187 // Load a shared library that is supported by the native bridge.
188 //
189 // Parameters:
190 // libpath [IN] path to the shared library
191 // flag [IN] the stardard RTLD_XXX defined in bionic dlfcn.h
192 // Returns:
193 // The opaque handle of the shared library if sucessful, otherwise NULL
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800194 //
195 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
196 // Use loadLibraryExt instead in namespace scenario.
Calin Juravle961ae122014-08-11 16:11:59 +0100197 void* (*loadLibrary)(const char* libpath, int flag);
198
199 // Get a native bridge trampoline for specified native method. The trampoline has same
200 // sigature as the native method.
201 //
202 // Parameters:
203 // handle [IN] the handle returned from loadLibrary
204 // shorty [IN] short descriptor of native method
205 // len [IN] length of shorty
206 // Returns:
207 // address of trampoline if successful, otherwise NULL
208 void* (*getTrampoline)(void* handle, const char* name, const char* shorty, uint32_t len);
209
210 // Check whether native library is valid and is for an ABI that is supported by native bridge.
211 //
212 // Parameters:
213 // libpath [IN] path to the shared library
214 // Returns:
215 // TRUE if library is supported by native bridge, FALSE otherwise
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800216 //
217 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
218 // Use isPathSupported instead in namespace scenario.
Calin Juravle961ae122014-08-11 16:11:59 +0100219 bool (*isSupported)(const char* libpath);
jgu21ab0da5a2014-09-10 06:58:32 -0400220
221 // Provide environment values required by the app running with native bridge according to the
222 // instruction set.
223 //
224 // Parameters:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800225 // instruction_set [IN] the instruction set of the app
jgu21ab0da5a2014-09-10 06:58:32 -0400226 // Returns:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800227 // NULL if not supported by native bridge.
228 // Otherwise, return all environment values to be set after fork.
jgu21ab0da5a2014-09-10 06:58:32 -0400229 const struct NativeBridgeRuntimeValues* (*getAppEnv)(const char* instruction_set);
Andreas Gampea6ac9ce2015-04-30 20:39:12 -0700230
231 // Added callbacks in version 2.
232
233 // Check whether the bridge is compatible with the given version. A bridge may decide not to be
234 // forwards- or backwards-compatible, and libnativebridge will then stop using it.
235 //
236 // Parameters:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800237 // bridge_version [IN] the version of libnativebridge.
Andreas Gampea6ac9ce2015-04-30 20:39:12 -0700238 // Returns:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800239 // true if the native bridge supports the given version of libnativebridge.
Andreas Gampea6ac9ce2015-04-30 20:39:12 -0700240 bool (*isCompatibleWith)(uint32_t bridge_version);
241
242 // A callback to retrieve a native bridge's signal handler for the specified signal. The runtime
243 // will ensure that the signal handler is being called after the runtime's own handler, but before
244 // all chained handlers. The native bridge should not try to install the handler by itself, as
245 // that will potentially lead to cycles.
246 //
247 // Parameters:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800248 // signal [IN] the signal for which the handler is asked for. Currently, only SIGSEGV is
Andreas Gampea6ac9ce2015-04-30 20:39:12 -0700249 // supported by the runtime.
250 // Returns:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800251 // NULL if the native bridge doesn't use a handler or doesn't want it to be managed by the
252 // runtime.
253 // Otherwise, a pointer to the signal handler.
Andreas Gampea6ac9ce2015-04-30 20:39:12 -0700254 NativeBridgeSignalHandlerFn (*getSignalHandler)(int signal);
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800255
256 // Added callbacks in version 3.
257
258 // Decrements the reference count on the dynamic library handler. If the reference count drops
259 // to zero then the dynamic library is unloaded.
260 //
261 // Parameters:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800262 // handle [IN] the handler of a dynamic library.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800263 //
264 // Returns:
265 // 0 on success, and nonzero on error.
266 int (*unloadLibrary)(void* handle);
267
268 // Dump the last failure message of native bridge when fail to load library or search symbol.
269 //
270 // Parameters:
271 //
272 // Returns:
273 // A string describing the most recent error that occurred when load library
274 // or lookup symbol via native bridge.
Dimitry Ivanovd836ab02016-11-02 18:03:10 -0700275 const char* (*getError)();
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800276
277 // Check whether library paths are supported by native bridge.
278 //
279 // Parameters:
280 // library_path [IN] search paths for native libraries (directories separated by ':')
281 // Returns:
282 // TRUE if libraries within search paths are supported by native bridge, FALSE otherwise
283 //
284 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
285 // Use isSupported instead in non-namespace scenario.
286 bool (*isPathSupported)(const char* library_path);
287
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800288 // Initializes anonymous namespace at native bridge side.
289 // NativeBridge's peer of android_init_anonymous_namespace() of dynamic linker.
290 //
291 // The anonymous namespace is used in the case when a NativeBridge implementation
292 // cannot identify the caller of dlopen/dlsym which happens for the code not loaded
293 // by dynamic linker; for example calls from the mono-compiled code.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800294 //
295 // Parameters:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800296 // public_ns_sonames [IN] the name of "public" libraries.
297 // anon_ns_library_path [IN] the library search path of (anonymous) namespace.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800298 // Returns:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800299 // true if the pass is ok.
300 // Otherwise, false.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800301 //
302 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
303 // Should not use in non-namespace scenario.
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800304 bool (*initAnonymousNamespace)(const char* public_ns_sonames, const char* anon_ns_library_path);
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800305
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800306 // Create new namespace in which native libraries will be loaded.
307 // NativeBridge's peer of android_create_namespace() of dynamic linker.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800308 //
309 // Parameters:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800310 // name [IN] the name of the namespace.
311 // ld_library_path [IN] the first set of library search paths of the namespace.
312 // default_library_path [IN] the second set of library search path of the namespace.
313 // type [IN] the attribute of the namespace.
314 // permitted_when_isolated_path [IN] the permitted path for isolated namespace(if it is).
315 // parent_ns [IN] the pointer of the parent namespace to be inherited from.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800316 // Returns:
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800317 // native_bridge_namespace_t* for created namespace or nullptr in the case of error.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800318 //
319 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
320 // Should not use in non-namespace scenario.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000321 struct native_bridge_namespace_t* (*createNamespace)(const char* name,
322 const char* ld_library_path,
323 const char* default_library_path,
324 uint64_t type,
325 const char* permitted_when_isolated_path,
326 struct native_bridge_namespace_t* parent_ns);
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800327
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800328 // Creates a link which shares some libraries from one namespace to another.
329 // NativeBridge's peer of android_link_namespaces() of dynamic linker.
330 //
331 // Parameters:
332 // from [IN] the namespace where libraries are accessed.
333 // to [IN] the namespace where libraries are loaded.
334 // shared_libs_sonames [IN] the libraries to be shared.
335 //
336 // Returns:
337 // Whether successed or not.
338 //
339 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
340 // Should not use in non-namespace scenario.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000341 bool (*linkNamespaces)(struct native_bridge_namespace_t* from,
342 struct native_bridge_namespace_t* to, const char* shared_libs_sonames);
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800343
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800344 // Load a shared library within a namespace.
Zhenhua WANGe8fb11d2017-02-27 10:14:45 +0800345 // NativeBridge's peer of android_dlopen_ext() of dynamic linker, only supports namespace
346 // extension.
Zhenhua WANGf2804e52016-05-30 11:16:08 +0800347 //
348 // Parameters:
349 // libpath [IN] path to the shared library
350 // flag [IN] the stardard RTLD_XXX defined in bionic dlfcn.h
351 // ns [IN] the pointer of the namespace in which the library should be loaded.
352 // Returns:
353 // The opaque handle of the shared library if sucessful, otherwise NULL
354 //
355 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
356 // Use loadLibrary instead in non-namespace scenario.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000357 void* (*loadLibraryExt)(const char* libpath, int flag, struct native_bridge_namespace_t* ns);
Dimitry Ivanov882cad22017-05-01 15:12:49 -0700358
359 // Get native bridge version of vendor namespace.
360 // The vendor namespace is the namespace used to load vendor public libraries.
361 // With O release this namespace can be different from the default namespace.
362 // For the devices without enable vendor namespaces this function should return null
363 //
364 // Returns:
365 // vendor namespace or null if it was not set up for the device
dimitryd2ace382019-02-04 15:06:43 +0100366 //
367 // Starting with v5 (Android Q) this function is no longer used.
368 // Use getExportedNamespace() below.
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000369 struct native_bridge_namespace_t* (*getVendorNamespace)();
dimitryd2ace382019-02-04 15:06:43 +0100370
371 // Get native bridge version of exported namespace. Peer of
372 // android_get_exported_namespace(const char*) function.
373 //
374 // Returns:
375 // exported namespace or null if it was not set up for the device
376 struct native_bridge_namespace_t* (*getExportedNamespace)(const char* name);
Calin Juravle961ae122014-08-11 16:11:59 +0100377};
378
379// Runtime interfaces to native bridge.
380struct NativeBridgeRuntimeCallbacks {
381 // Get shorty of a Java method. The shorty is supposed to be persistent in memory.
382 //
383 // Parameters:
384 // env [IN] pointer to JNIenv.
385 // mid [IN] Java methodID.
386 // Returns:
387 // short descriptor for method.
388 const char* (*getMethodShorty)(JNIEnv* env, jmethodID mid);
389
390 // Get number of native methods for specified class.
391 //
392 // Parameters:
393 // env [IN] pointer to JNIenv.
394 // clazz [IN] Java class object.
395 // Returns:
396 // number of native methods.
397 uint32_t (*getNativeMethodCount)(JNIEnv* env, jclass clazz);
398
399 // Get at most 'method_count' native methods for specified class 'clazz'. Results are outputed
400 // via 'methods' [OUT]. The signature pointer in JNINativeMethod is reused as the method shorty.
401 //
402 // Parameters:
403 // env [IN] pointer to JNIenv.
404 // clazz [IN] Java class object.
405 // methods [OUT] array of method with the name, shorty, and fnPtr.
406 // method_count [IN] max number of elements in methods.
407 // Returns:
408 // number of method it actually wrote to methods.
409 uint32_t (*getNativeMethods)(JNIEnv* env, jclass clazz, JNINativeMethod* methods,
410 uint32_t method_count);
411};
412
Nicolas Geoffrayd9b4d9b2019-01-10 16:27:54 +0000413#ifdef __cplusplus
414} // extern "C"
415} // namespace android
416#endif // __cplusplus
Calin Juravle961ae122014-08-11 16:11:59 +0100417
418#endif // NATIVE_BRIDGE_H_