Skip to content

Commit 92ff52e

Browse files
author
Mihail Slavchev
committed
refactor JNI initialization
1 parent 8a4c7e0 commit 92ff52e

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/jni/NativePlatform.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int AppJavaObjectID = -1;
4242
int count = 0;
4343
SimpleAllocator g_allocator;
4444

45-
jint NativePlatform::JNI_ON_LOAD(JavaVM *vm, void *reserved)
45+
void NativePlatform::Init(JavaVM *vm, void *reserved)
4646
{
4747
__android_log_print(ANDROID_LOG_INFO, "TNS.Native", "NativeScript Runtime Version %s, commit %s", NATIVE_SCRIPT_RUNTIME_VERSION, NATIVE_SCRIPT_RUNTIME_COMMIT_SHA);
4848
DEBUG_WRITE("JNI_ONLoad");
@@ -57,8 +57,6 @@ jint NativePlatform::JNI_ON_LOAD(JavaVM *vm, void *reserved)
5757
}
5858

5959
DEBUG_WRITE("JNI_ONLoad END");
60-
61-
return JNI_VERSION_1_6;
6260
}
6361

6462
Isolate* NativePlatform::InitNativeScript(JNIEnv *_env, jobject obj, jstring filesPath, jint appJavaObjectId, jboolean verboseLoggingEnabled, jstring packageName, jobjectArray args, jobject jsDebugger)

src/jni/NativePlatform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace tns
1515
class NativePlatform
1616
{
1717
public:
18-
static jint JNI_ON_LOAD(JavaVM *vm, void *reserved);
18+
static void Init(JavaVM *vm, void *reserved);
1919
static v8::Isolate* InitNativeScript(JNIEnv *_env, jobject obj, jstring filesPath, jint appJavaObjectId, jboolean verboseLoggingEnabled, jstring packageName, jobjectArray args, jobject jsDebugger);
2020
static void RunModule(JNIEnv *_env, jobject obj, jstring scriptFile);
2121
static jobject RunScript(JNIEnv *_env, jobject obj, jstring scriptFile);

src/jni/com_tns_Platform.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
1313
{
1414
try
1515
{
16-
return NativePlatform::JNI_ON_LOAD(vm, reserved);
16+
NativePlatform::Init(vm, reserved);
1717
}
1818
catch (NativeScriptException& e)
1919
{
@@ -29,6 +29,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
2929
NativeScriptException nsEx(std::string("Error: c++ exception!"));
3030
nsEx.ReThrowToJava();
3131
}
32+
33+
return JNI_VERSION_1_6;
3234
}
3335

3436
extern "C" void Java_com_tns_Platform_initNativeScript(JNIEnv *_env, jobject obj, jstring filesPath, jint appJavaObjectId, jboolean verboseLoggingEnabled, jstring packageName, jobjectArray args, jobject jsDebugger)

0 commit comments

Comments
 (0)