Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
throw the right exception corresponding to TimeoutFailureException
[simgrid.git] / src / java / jmsg.c
index 24d1413..b18f5df 100644 (file)
 #include "jmsg_application_handler.h"
 #include "jxbt_utilities.h"
 
-
 #include "jmsg.h"
-
 #include "msg/mailbox.h"
-
 #include "surf/surfxml_parse.h"
 
-
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
 static JavaVM *__java_vm = NULL;
@@ -54,7 +50,6 @@ static jobject native_to_java_process(m_process_t process)
           (process->simdata->s_process->context))->jprocess;
 }
 
-
 /*
  * The MSG process connected functions implementation.                                 
  */
@@ -174,7 +169,7 @@ Java_simgrid_msg_MsgNative_processResume(JNIEnv * env, jclass cls,
   m_process_t process = jprocess_to_native_process(jprocess, env);
 
   if (!process) {
-    jxbt_throw_notbound(env, "process", jprocess);
+    jxbt_throw_notbound(env,"process", jprocess);
     return;
   }
 
@@ -986,14 +981,26 @@ Java_simgrid_msg_MsgNative_taskSend(JNIEnv * env, jclass cls,
 
   (*env)->ReleaseStringUTFChars(env, jalias, alias);
 
-  /* FIXME throw the right exception corresponding to HostFailureException, TransferFailureException, TimeoutFailureException
+  /*  throw the right exception corresponding to HostFailureException, TransferFailureException, TimeoutFailureException
    * Note: these exceptions must be created beforehand
    *       then, you want to create some functions like jxbt_throw_notbound()
    *       then, you must declare in the MsgNative stuff that these native functions can throw these exceptions
    */
   if (MSG_OK != rv)
-    jxbt_throw_native(env, xbt_strdup("MSG_task_send_with_timeout() failed"));
-
+  {
+    
+      if ( rv == MSG_TRANSFER_FAILURE )
+       jxbt_throw_transfer_failure(env,MSG_task_get_name(task),alias);
+       
+      else if ( rv == MSG_HOST_FAILURE )
+       jxbt_throw_host_failure(env,MSG_task_get_name(task),alias);
+       
+      else if ( rv == MSG_TIMEOUT_FAILURE )
+        jxbt_throw_time_out_failure(env,MSG_task_get_name(task),alias);
+      else
+       jxbt_throw_native(env, xbt_strdup("MSG_task_send_with_timeout() failed"));
+  
+  } 
 }
 
 JNIEXPORT void JNICALL
@@ -1074,7 +1081,6 @@ JNIEXPORT jint JNICALL
 Java_simgrid_msg_MsgNative_taskListenFromHost(JNIEnv * env, jclass cls,
                                               jstring jalias, jobject jhost)
 {
-
   int rv;
   const char *alias;
 
@@ -1084,7 +1090,6 @@ Java_simgrid_msg_MsgNative_taskListenFromHost(JNIEnv * env, jclass cls,
     jxbt_throw_notbound(env, "host", jhost);
     return -1;
   }
-
   alias = (*env)->GetStringUTFChars(env, jalias, 0);
 
   rv = MSG_task_listen_from_host(alias, host);