Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Trying to fix another java bug
[simgrid.git] / src / java / jmsg.c
index f16f2c7..522b77f 100644 (file)
@@ -12,7 +12,7 @@
 #include "msg/msg.h"
 #include "msg/private.h"
 #include "simix/private.h"
-#include "xbt/xbt_context_java.h"
+#include "simix/smx_context_java.h"
 
 #include "jmsg_process.h"
 #include "jmsg_host.h"
@@ -51,8 +51,8 @@ JNIEnv *get_current_thread_env(void)
 
 static jobject native_to_java_process(m_process_t process)
 {
-  return ((xbt_ctx_java_t)
-          (process->simdata->s_process->simdata->context))->jprocess;
+  return ((smx_ctx_java_t)
+          (process->simdata->s_process->context))->jprocess;
 }
 
 
@@ -950,6 +950,7 @@ Java_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
 
   MSG_global_init(&argc, argv);
   MSG_set_channel_number(10);   /* FIXME: this should not be fixed statically */
+  SIMIX_context_select_factory("java");
 
   for (index = 0; index < argc; index++)
     free(argv[index]);
@@ -968,10 +969,11 @@ JNIEXPORT void JNICALL
   jobject jhost;
 
   /* Run everything */
-  if (MSG_OK != MSG_main())
+  if (MSG_OK != MSG_main()) {
+    CRITICAL0("We are here!");
     jxbt_throw_native(env, xbt_strdup("MSG_main() failed"));
-
-  DEBUG0
+  }
+  INFO0
     ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
 
   DEBUG0("Clean java world");
@@ -983,11 +985,13 @@ JNIEXPORT void JNICALL
       jhost_unref(env, jhost);
   }
 
-  DEBUG0("Clean native world");
+  INFO0("Clean native world");
   /* cleanup native stuff */
-  if (MSG_OK != MSG_clean())
+  if (MSG_OK != MSG_clean()){
+    CRITICAL0("We are there!");
     jxbt_throw_native(env, xbt_strdup("MSG_main() failed"));
-
+  }
+  INFO0("All good");
 }
 
 JNIEXPORT jint JNICALL
@@ -1021,7 +1025,7 @@ Java_simgrid_msg_MsgNative_processExit(JNIEnv * env, jclass cls,
     return;
   }
 
-  xbt_context_stop(0);
+  SIMIX_context_stop(SIMIX_process_self()->context);
 }
 
 JNIEXPORT void JNICALL
@@ -1097,7 +1101,7 @@ Java_simgrid_msg_MsgNative_selectContextFactory(JNIEnv * env, jclass class,
   const char *name = (*env)->GetStringUTFChars(env, jname, 0);
 
   TRY {
-    xbt_context_select_factory(name);
+    SIMIX_context_select_factory(name);
   } CATCH(e) {
     errmsg = xbt_strdup(e.msg);
     xbt_ex_free(e);