MCPcopy Create free account
hub / github.com/cuberite/cuberite / CallJavaFunction_Void_String

Function CallJavaFunction_Void_String

Android/jni/ToJava.h:12–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10//__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
11
12static void CallJavaFunction_Void_String( jobject a_Object, const std::string & a_FunctionName, const std::string & a_StringParam )
13{
14 JNIEnv * oldEnv = g_CurrentJNIEnv;
15 int status = g_JavaVM->AttachCurrentThread(&g_CurrentJNIEnv, NULL);
16 __android_log_print(ANDROID_LOG_ERROR,"MCServer", "STATUS: %i old: %p new: %p", status, oldEnv, g_CurrentJNIEnv );
17 jstring str = g_CurrentJNIEnv->NewStringUTF( a_StringParam.c_str() );
18
19
20 //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object );
21 jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object );
22 //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls );
23 jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "(Ljava/lang/String;)V"); // void a_FunctionName( String )
24 //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid );
25 if (mid != 0)
26 {
27
28 __android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() );
29 g_CurrentJNIEnv->CallVoidMethod( a_Object, mid, str );
30 }
31 else
32 {
33 __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" );
34 }
35
36 if( oldEnv != g_CurrentJNIEnv )
37 {
38 g_JavaVM->DetachCurrentThread();
39 }
40}
41
42
43static void CallJavaFunction_Void_Void( jobject a_Object, const std::string & a_FunctionName )

Callers

nothing calls this directly

Calls 1

c_strMethod · 0.80

Tested by

no test coverage detected