Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Kill cojava
[simgrid.git] / src / bindings / java / jmsg_process.c
index ed259b7..a7b3a3f 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java process instances.                         */
 
-/* Copyright (c) 2007-2014. The SimGrid Team.
+/* Copyright (c) 2007-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -12,7 +12,6 @@
 #include "jmsg_host.h"
 #include "jxbt_utilities.h"
 #include "smx_context_java.h"
-#include "smx_context_cojava.h"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
@@ -26,11 +25,7 @@ jfieldID jprocess_field_Process_ppid;
 
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject jprocess) {
-  if (smx_factory_initializer_to_use == SIMIX_ctx_cojava_factory_init) {
-    msg_process_t process = jprocess_to_native_process(jprocess, env);
-    smx_context_t context = MSG_process_get_smx_ctx(process);
-    smx_ctx_cojava_stop(context);
-  }
+
 }
 
 jobject native_to_java_process(msg_process_t process)
@@ -131,7 +126,7 @@ Java_org_simgrid_msg_Process_create(JNIEnv * env,
   }
 
   /* bind/retrieve the msg host */
-  host = MSG_get_host_by_name(hostname);
+  host = MSG_host_by_name(hostname);
 
   if (!(host)) {    /* not bound */
     jxbt_throw_host_not_found(env, hostname);
@@ -225,7 +220,7 @@ Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject
   return jproperty;
 }
 JNIEXPORT jobject JNICALL
-Java_org_simgrid_msg_Process_currentProcess(JNIEnv * env, jclass cls)
+Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv * env, jclass cls)
 {
   msg_process_t process = MSG_process_self();
   jobject jprocess;
@@ -340,7 +335,16 @@ Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint
   msg_error_t rv;
   rv = MSG_process_sleep(time);
   if (rv != MSG_OK) {
-    jmsg_throw_status(env,rv);
+    XBT_DEBUG("Something during the MSG_process_sleep invocation was wrong, trigger a HostFailureException");
+
+    //jmsg_throw_status(env,rv);
+
+    // adsein, the code above as been replaced by the code below. Indeed, according to the documentation, a sleep can only 
+    // trigger a host_failure exception. When the sleep crashes due to a host shutdown, the exception thrown by smx_context_java.c
+    // is a cancelled_error, see bindings/java/smx_context_java.c, function void smx_ctx_java_stop(smx_context_t context) and src/msg/msg_gos.c
+    // function  msg_error_t MSG_process_sleep(double nb_sec)
+
+    jxbt_throw_host_failure(env,NULL);
   }
 }
 JNIEXPORT void JNICALL
@@ -405,12 +409,5 @@ Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdoubl
 
 JNIEXPORT jint JNICALL
 Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls) {
-       /* The next test on SimGrid version is to ensure that this still compiles with SG 3.8 while the C function were added in SG 3.9 only.
-        * This kind of pimple becomes mandatory when you get so slow to release the java version that it begins evolving further after the C release date.
-        */
-#if SIMGRID_VERSION >= 30900
   return (jint) MSG_process_get_number();
-#else
-  return (jint) -1;
-#endif
 }