Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow task name to be null
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 27 Feb 2010 23:06:35 +0000 (23:06 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 27 Feb 2010 23:06:35 +0000 (23:06 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7141 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/java/jmsg.c

index c1d65df..43a31a4 100644 (file)
@@ -518,7 +518,7 @@ Java_simgrid_msg_MsgNative_taskCreate(JNIEnv * env, jclass cls, jobject jtask,
                                       jdouble jmessageSize)
 {
   m_task_t task;                /* the native task to create                            */
                                       jdouble jmessageSize)
 {
   m_task_t task;                /* the native task to create                            */
-  const char *name;             /* the name of the task                                 */
+  const char *name=NULL;        /* the name of the task                                 */
 
   if (jcomputeDuration < 0) {
     jxbt_throw_illegal(env,
 
   if (jcomputeDuration < 0) {
     jxbt_throw_illegal(env,
@@ -534,20 +534,19 @@ Java_simgrid_msg_MsgNative_taskCreate(JNIEnv * env, jclass cls, jobject jtask,
     return;
   }
 
     return;
   }
 
-  if (!jname) {
-    jxbt_throw_null(env, xbt_strdup("Task name cannot be null"));
-    return;
+  if (jname) {
+    /* get the C string from the java string */
+    name = (*env)->GetStringUTFChars(env, jname, 0);
   }
 
   }
 
-  /* get the C string from the java string */
-  name = (*env)->GetStringUTFChars(env, jname, 0);
 
   /* create the task */
   task =
     MSG_task_create(name, (double) jcomputeDuration, (double) jmessageSize,
                     NULL);
 
 
   /* create the task */
   task =
     MSG_task_create(name, (double) jcomputeDuration, (double) jmessageSize,
                     NULL);
 
-  (*env)->ReleaseStringUTFChars(env, jname, name);
+  if (jname)
+    (*env)->ReleaseStringUTFChars(env, jname, name);
 
   /* bind & store the task */
   jtask_bind(jtask, task, env);
 
   /* bind & store the task */
   jtask_bind(jtask, task, env);