Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
java: inline a function and don't leak a global ref
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Mar 2017 06:25:22 +0000 (07:25 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Mar 2017 06:25:22 +0000 (07:25 +0100)
src/bindings/java/jmsg_process.cpp
src/bindings/java/jmsg_process.h

index 16a109d..2ed2a92 100644 (file)
@@ -51,12 +51,6 @@ void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env)
   env->SetLongField(jprocess, jprocess_field_Process_bind, (intptr_t)process);
 }
 
-jstring jprocess_get_name(jobject jprocess, JNIEnv * env)
-{
-  jstring jname = (jstring) env->GetObjectField(jprocess, jprocess_field_Process_name);
-  return (jstring) env->NewGlobalRef(jname);
-}
-
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls) {
   jclass jprocess_class_Process = env->FindClass("org/simgrid/msg/Process");
   xbt_assert(jprocess_class_Process, "Native initialization of msg/Process failed. Please report that bug");
@@ -78,7 +72,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv* env, jobject
   jobject jprocess = jprocess_ref(jprocess_arg, env);
 
   /* Actually build the MSG process */
-  jstring jname         = jprocess_get_name(jprocess_arg, env);
+  jstring jname         = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
   const char* name      = env->GetStringUTFChars(jname, 0);
   msg_process_t process = MSG_process_create_from_stdfunc(
       name, [jprocess]() -> void { simgrid::kernel::context::java_main_jprocess(jprocess); },
index 90b449e..f771824 100644 (file)
@@ -41,9 +41,6 @@ jobject jprocess_from_native(msg_process_t process);
 /** Extract the native instance from the java one */
 msg_process_t jprocess_to_native(jobject jprocess, JNIEnv* env);
 
-/** Get the name of a java instance. */
-jstring jprocess_get_name(jobject jprocess, JNIEnv* env);
-
 /** Initialize the native world, called from the Java world at startup */
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);