X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/82791f187dbb46144e40afb1a2b6a467df41dbc1..3af9dcb5714db015a7038a58701b2b453f52c6ca:/src/bindings/java/jmsg.c diff --git a/src/bindings/java/jmsg.c b/src/bindings/java/jmsg.c index 6c4b587462..3599905e4c 100644 --- a/src/bindings/java/jmsg.c +++ b/src/bindings/java/jmsg.c @@ -1,6 +1,6 @@ /* Java Wrappers to the MSG API. */ -/* Copyright (c) 2007-2012. The SimGrid Team. +/* Copyright (c) 2007-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -16,6 +16,8 @@ #include "jmsg_process.h" +#include "jmsg_as.h" + #include "jmsg_host.h" #include "jmsg_task.h" #include "jxbt_utilities.h" @@ -62,7 +64,7 @@ void jmsg_throw_status(JNIEnv *env, msg_error_t status) { jxbt_throw_host_failure(env,NULL); break; default: - jxbt_throw_native(env,bprintf("communication failed")); + jxbt_throw_native(env,xbt_strdup("communication failed")); } } @@ -144,8 +146,7 @@ JNIEXPORT void JNICALL rv = MSG_main(); XBT_DEBUG("Done running MSG_MAIN"); jxbt_check_res("MSG_main()", rv, MSG_OK, - bprintf - ("unexpected error : MSG_main() failed .. please report this bug ")); + xbt_strdup("unexpected error : MSG_main() failed .. please report this bug ")); XBT_INFO("MSG_main finished; Cleaning up the simulation..."); /* Cleanup java hosts */ @@ -171,6 +172,26 @@ Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, (*env)->ReleaseStringUTFChars(env, jplatformFile, platformFile); } + +JNIEXPORT jobject JNICALL +Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls) +{ + msg_as_t as = MSG_environment_get_routing_root(); + jobject jas = jas_new_instance(env); + if (!jas) { + jxbt_throw_jni(env, "java As instantiation failed"); + return NULL; + } + jas = jas_ref(env, jas); + if (!jas) { + jxbt_throw_jni(env, "new global ref allocation failed"); + return NULL; + } + jas_bind(jas, as, env); + + return (jobject) jas; +} + JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv * env, jclass cls, jstring js) { @@ -236,7 +257,7 @@ static int create_jprocess(int argc, char *argv[]) { jclass class_Process = (*env)->FindClass(env, argv[0]); xbt_str_subst(argv[0],'/','.',0); //Retrieve the methodID for the constructor - xbt_assert((class_Process != NULL), "Class not found."); + xbt_assert((class_Process != NULL), "Class not found (%s).", argv[0]); jmethodID constructor_Process = (*env)->GetMethodID(env, class_Process, "", "(Lorg/simgrid/msg/Host;Ljava/lang/String;[Ljava/lang/String;)V"); xbt_assert((constructor_Process != NULL), "Constructor not found for class %s. Is there a (Host, String ,String[]) constructor in your class ?", argv[0]);