- process->name = xbt_strdup(name);
- (*env)->ReleaseStringUTFChars(env, jname, name);
-
- process->simdata->m_host = jhost_get_native(env, jhost);
-
-
- if (!(process->simdata->m_host)) { /* not binded */
- free(process->simdata);
- free(process->data);
- free(process);
- jxbt_throw_notbound(env, "host", jhost);
- return;
- }
- process->simdata->PID = msg_global->PID++;
-
- /* create a new context */
- DEBUG8
- ("fill in process %s/%s (pid=%d) %p (sd=%p, host=%p, host->sd=%p); env=%p",
- process->name, process->simdata->m_host->name,
- process->simdata->PID, process, process->simdata,
- process->simdata->m_host, process->simdata->m_host->simdata, env);
-
- process->simdata->s_process =
- SIMIX_process_create(process->name, (xbt_main_func_t) jprocess,
- /*data */ (void *) process,
- process->simdata->m_host->simdata->
- smx_host->name, 0, NULL, NULL);
-
- DEBUG1("context created (s_process=%p)", process->simdata->s_process);
-
-
- if (SIMIX_process_self()) { /* someone created me */
- process->simdata->PPID =
- MSG_process_get_PID(SIMIX_process_self()->data);
- } else {
- process->simdata->PPID = -1;
- }
-
- process->simdata->last_errno = MSG_OK;
-
- /* add the process to the list of the processes of the simulation */
- xbt_fifo_unshift(msg_global->process_list, process);
-
- sprintf(alias, "%s:%s",
- (process->simdata->m_host->simdata->smx_host)->name,
- process->name);
-
- mailbox = MSG_mailbox_new(alias);
+ name = xbt_strdup(name);
+
+ /* Actually build the MSG process */
+ process = MSG_process_create_with_environment(name,
+ (xbt_main_func_t) jprocess,
+ /*data*/ NULL,
+ host,
+ /* kill_time */-1,
+ /*argc, argv, properties*/
+ 0,NULL,NULL);
+
+ MSG_process_set_data(process,&process);
+
+ /* release our reference to the process name (variable name becomes invalid) */
+ //FIXME : This line should be uncommented but with mac it doesn't work. BIG WARNING
+ //(*env)->ReleaseStringUTFChars(env, jname, name);
+ (*env)->ReleaseStringUTFChars(env, jhostname, hostname);
+
+ /* bind the java process instance to the native process */
+ jprocess_bind(jprocess, process, env);