From: coldpeace Date: Thu, 25 Mar 2010 10:51:38 +0000 (+0000) Subject: cleanups X-Git-Tag: SVN~373 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/16b973adc7848352f530190ec27096d902205afc cleanups git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7367 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/java/jmsg.c b/src/java/jmsg.c index 6bf0a01ad1..d7fcb2d92e 100644 --- a/src/java/jmsg.c +++ b/src/java/jmsg.c @@ -255,7 +255,7 @@ Java_simgrid_msg_MsgNative_processFromPID(JNIEnv * env, jclass cls, jint PID) } if (!native_to_java_process(process)) { - jxbt_throw_native(env, xbt_strdup("SIMIX_process_get_jprocess() failed")); + jxbt_throw_jni(env, "SIMIX_process_get_jprocess() failed"); return NULL; } @@ -299,14 +299,14 @@ Java_simgrid_msg_MsgNative_processSelf(JNIEnv * env, jclass cls) jobject jprocess; if (!process) { - jxbt_throw_native(env, xbt_strdup("MSG_process_self() failed")); + jxbt_throw_jni(env, xbt_strdup("MSG_process_self() failed")); return NULL; } jprocess = native_to_java_process(process); if (!jprocess) - jxbt_throw_native(env, xbt_strdup("SIMIX_process_get_jprocess() failed")); + jxbt_throw_jni(env, xbt_strdup("SIMIX_process_get_jprocess() failed")); return jprocess; } @@ -323,8 +323,11 @@ Java_simgrid_msg_MsgNative_processChangeHost(JNIEnv * env, jclass cls, } /* try to change the host of the process */ - if (MSG_OK != MSG_process_change_host(host)) - jxbt_throw_native(env, xbt_strdup("MSG_process_change_host() failed")); + MSG_error_t rv = MSG_process_change_host(host); + + jxbt_check_res("MSG_process_change_host()",rv,MSG_OK, + bprintf("unexpected error , please report this bug")); + } JNIEXPORT void JNICALL @@ -834,31 +837,36 @@ Java_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs) { JNIEXPORT void JNICALL JNICALL Java_simgrid_msg_Msg_run(JNIEnv * env, jclass cls) { - xbt_fifo_item_t item = NULL; - m_host_t host = NULL; + MSG_error_t rv; + int index;//xbt_fifo_item_t item = NULL; + m_host_t *hosts; jobject jhost; /* Run everything */ - if (MSG_OK != MSG_main()) { - jxbt_throw_native(env, xbt_strdup("MSG_main() failed")); - } + rv= MSG_main(); + jxbt_check_res("MSG_main()",rv,MSG_OK, + bprintf("unexpected error : MSG_main() failed .. please report this bug ")); + DEBUG0 ("MSG_main finished. Bail out before cleanup since there is a bug in this part."); DEBUG0("Clean java world"); /* Cleanup java hosts */ - xbt_fifo_foreach(msg_global->host, item, host, m_host_t) { - jhost = (jobject) host->data; + hosts = MSG_get_host_table(); + for (index=0;indexdata; + if(jhost) + jhost_unref(env,jhost); - if (jhost) - jhost_unref(env, jhost); } DEBUG0("Clean native world"); /* cleanup native stuff */ - if (MSG_OK != MSG_clean()){ - jxbt_throw_native(env, xbt_strdup("MSG_main() failed")); - } + rv = MSG_OK != MSG_clean(); + jxbt_check_res("MSG_clean()",rv,MSG_OK, + bprintf("unexpected error : MSG_clean() failed .. please report this bug ")); + } JNIEXPORT jint JNICALL @@ -968,7 +976,7 @@ Java_simgrid_msg_MsgNative_selectContextFactory(JNIEnv * env, jclass class, if (errmsg) { char *thrown = bprintf("xbt_select_context_factory() failed: %s", errmsg); free(errmsg); - jxbt_throw_native(env, thrown); + jxbt_throw_jni(env, thrown); } } @@ -1135,7 +1143,7 @@ Java_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, japplication_handler_on_start_document(); if (surf_parse()) - jxbt_throw_native(env, xbt_strdup("surf_parse() failed")); + jxbt_throw_jni(env,"surf_parse() failed"); surf_parse_close(); diff --git a/src/java/simgrid/msg/Msg.java b/src/java/simgrid/msg/Msg.java index 15dffa119a..40c9ea2d13 100644 --- a/src/java/simgrid/msg/Msg.java +++ b/src/java/simgrid/msg/Msg.java @@ -77,7 +77,7 @@ public final class Msg { * * @see MSG_run, MSG_clean */ - public final static native void run() throws NativeException; + public final static native void run() ; /** * The native implemented method to create the environment of the simulation. @@ -85,14 +85,14 @@ public final class Msg { * @param platformFile The XML file which contains the description of the environment of the simulation * */ - public final static native void createEnvironment(String platformFile) throws NativeException; + public final static native void createEnvironment(String platformFile); /** * The method to deploy the simulation. * * @param platformFile The XML file which contains the description of the application to deploy. */ - public final static native void deployApplication(String deploymentFile) throws NativeException; + public final static native void deployApplication(String deploymentFile); /** Example launcher. You can use it or provide your own launcher, as you wish */ static public void main(String[]args) throws MsgException { diff --git a/src/java/simgrid/msg/MsgNative.java b/src/java/simgrid/msg/MsgNative.java index aa7a3b9378..973e4df289 100644 --- a/src/java/simgrid/msg/MsgNative.java +++ b/src/java/simgrid/msg/MsgNative.java @@ -106,11 +106,9 @@ final class MsgNative { * * @return The process with the specified PID. * - * @exception NativeException if the SimGrid native code failed. - * * @see Process.getFromPID() */ - final static native Process processFromPID(int PID) throws NativeException; + final static native Process processFromPID(int PID) ; /** * The natively implemented method to get the PID of a MSG process.