/* Java Wrappers to the MSG API. */
-/* Copyright (c) 2007-2014. The SimGrid Team.
+/* Copyright (c) 2007-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <msg/msg.h>
+#include <simgrid/msg.h>
#include <simgrid/simix.h>
#include <surf/surfxml_parse.h>
#include <locale.h>
case MSG_HOST_FAILURE:
jxbt_throw_host_failure(env,NULL);
break;
+ case MSG_TASK_CANCELED:
+ jxbt_throw_task_cancelled(env,NULL);
+ break;
default:
- jxbt_throw_native(env,xbt_strdup("communication failed"));
+ jxbt_throw_native(env,xbt_strdup("undefined message failed (please see jmsg_throw_status function in jmsg.c)"));
}
}
const char *tmp;
XBT_LOG_CONNECT(jmsg);
-#ifdef HAVE_TRACING
XBT_LOG_CONNECT(jtrace);
-#endif
(*env)->GetJavaVM(env, &__java_vm);
argc++;
argv = xbt_new(char *, argc + 1);
- argv[0] = strdup("java");
+ argv[0] = xbt_strdup("java");
for (index = 0; index < argc - 1; index++) {
jval = (jstring) (*env)->GetObjectArrayElement(env, jargs, index);
tmp = (*env)->GetStringUTFChars(env, jval, 0);
- argv[index + 1] = strdup(tmp);
+ argv[index + 1] = xbt_strdup(tmp);
(*env)->ReleaseStringUTFChars(env, jval, tmp);
}
argv[argc] = NULL;
/* Cleanup java storages */
storages = MSG_storages_as_dynar();
- for (index = 0; index < xbt_dynar_length(storages) - 1; index++) {
- jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);
- if (jstorage)
- jstorage_unref(env, jstorage);
-
+ if(!xbt_dynar_is_empty(storages)){
+ for (index = 0; index < xbt_dynar_length(storages) - 1; index++) {
+ jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);
+ if (jstorage)
+ jstorage_unref(env, jstorage);
+ }
}
xbt_dynar_free(&storages);
return 0;
}
-