summaryrefslogtreecommitdiffstats
path: root/test/115-native-bridge
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-08-12 20:55:20 +0100
committerCalin Juravle <calin@google.com>2014-08-15 10:10:09 +0100
commitc8423521c1d1136c70b153479b7df3bf4fd7fc2a (patch)
treef7a0d12391f843d1b1eac1b0227c3237e7da3920 /test/115-native-bridge
parent02a6317297b8745637b265ab75abbfa685879882 (diff)
downloadart-c8423521c1d1136c70b153479b7df3bf4fd7fc2a.zip
art-c8423521c1d1136c70b153479b7df3bf4fd7fc2a.tar.gz
art-c8423521c1d1136c70b153479b7df3bf4fd7fc2a.tar.bz2
[ART] Move to system/core native bridge library
Some cleanups on the way: - move NativeBridgeRuntimeCallbacks from a global to a field - rename native_bridge_library_string to the more suggestive navtive_bridge_library_path - clean up imports Bug: 16884833 Change-Id: I73aab8e212860ba5aee9444d801806d3da326a41
Diffstat (limited to 'test/115-native-bridge')
-rw-r--r--test/115-native-bridge/nativebridge.cc28
1 files changed, 6 insertions, 22 deletions
diff --git a/test/115-native-bridge/nativebridge.cc b/test/115-native-bridge/nativebridge.cc
index 268f0be..3acc643 100644
--- a/test/115-native-bridge/nativebridge.cc
+++ b/test/115-native-bridge/nativebridge.cc
@@ -22,27 +22,9 @@
#include "jni.h"
#include "stdio.h"
-#include "string.h"
#include "unistd.h"
-#include "native_bridge.h"
-
-
-// Native bridge interfaces...
-
-struct NativeBridgeArtCallbacks {
- const char* (*getMethodShorty)(JNIEnv* env, jmethodID mid);
- uint32_t (*getNativeMethodCount)(JNIEnv* env, jclass clazz);
- uint32_t (*getNativeMethods)(JNIEnv* env, jclass clazz, JNINativeMethod* methods,
- uint32_t method_count);
-};
-
-struct NativeBridgeCallbacks {
- bool (*initialize)(NativeBridgeArtCallbacks* art_cbs);
- void* (*loadLibrary)(const char* libpath, int flag);
- void* (*getTrampoline)(void* handle, const char* name, const char* shorty, uint32_t len);
- bool (*isSupported)(const char* libpath);
-};
+#include "nativebridge/native_bridge.h"
struct NativeBridgeMethod {
const char* name;
@@ -53,7 +35,7 @@ struct NativeBridgeMethod {
};
static NativeBridgeMethod* find_native_bridge_method(const char *name);
-static NativeBridgeArtCallbacks* gNativeBridgeArtCallbacks;
+static const android::NativeBridgeRuntimeCallbacks* gNativeBridgeArtCallbacks;
static jint trampoline_JNI_OnLoad(JavaVM* vm, void* reserved) {
JNIEnv* env = nullptr;
@@ -225,7 +207,7 @@ static NativeBridgeMethod* find_native_bridge_method(const char *name) {
}
// NativeBridgeCallbacks implementations
-extern "C" bool native_bridge_initialize(NativeBridgeArtCallbacks* art_cbs) {
+extern "C" bool native_bridge_initialize(const android::NativeBridgeRuntimeCallbacks* art_cbs) {
if (art_cbs != nullptr) {
gNativeBridgeArtCallbacks = art_cbs;
printf("Native bridge initialized.\n");
@@ -281,7 +263,9 @@ extern "C" bool native_bridge_isSupported(const char* libpath) {
return strcmp(libpath, "libjavacore.so") != 0;
}
-NativeBridgeCallbacks NativeBridgeItf {
+// "NativeBridgeItf" is effectively an API (it is the name of the symbol that will be loaded
+// by the native bridge library).
+android::NativeBridgeCallbacks NativeBridgeItf {
.initialize = &native_bridge_initialize,
.loadLibrary = &native_bridge_loadLibrary,
.getTrampoline = &native_bridge_getTrampoline,