Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more informative message when a process gets killed
[simgrid.git] / src / bindings / java / smx_context_java.c
index bb36804..ce2d01e 100644 (file)
@@ -96,7 +96,7 @@ static void* smx_ctx_java_thread_run(void *data) {
   xbt_os_thread_set_extra_data(context);
   //Attach the thread to the JVM
   JNIEnv *env;
-  jint error = (*__java_vm)->AttachCurrentThread(__java_vm, (void **) &env, NULL);
+  _XBT_GNUC_UNUSED jint error = (*__java_vm)->AttachCurrentThread(__java_vm, (void **) &env, NULL);
   xbt_assert((error == JNI_OK), "The thread could not be attached to the JVM");
   context->jenv = get_current_thread_env();
   //Wait for the first scheduling round to happen.
@@ -154,16 +154,15 @@ void smx_ctx_java_stop(smx_context_t context)
     context->iwannadie = 0;
     JNIEnv *env = get_current_thread_env();
     XBT_DEBUG("Gonnal launch Killed Error");
-    jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", xbt_strdup("Process killed :)"));
-    // TODO emptty/adsein, comment the following line. This avoid to raise process cancelled exception at the Java level but 
-    // it impacts the shutdown of VMs :( see java-cloud example
-       THROWF(cancel_error, 0, "process cancelled");
+    jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", bprintf("Process %s killed: ", MSG_process_get_name( (msg_process_t)context)));
+    XBT_DEBUG("Trigger a cancel error at the C level");
+    THROWF(cancel_error, 0, "process cancelled");
   } else {
     smx_ctx_base_stop(context);
     /* detach the thread and kills it */
     JNIEnv *env = ctx_java->jenv;
     (*env)->DeleteGlobalRef(env,ctx_java->jprocess);
-    jint error = (*__java_vm)->DetachCurrentThread(__java_vm);
+    _XBT_GNUC_UNUSED jint error = (*__java_vm)->DetachCurrentThread(__java_vm);
     xbt_assert((error == JNI_OK), "The thread couldn't be detached.");
     xbt_os_sem_release(((smx_ctx_java_t)context)->end);
     xbt_os_thread_exit(NULL);