/* 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 "xbt/str.h"
+#include <xbt/dict.h>
+#include <xbt/dynar.h>
+#include <xbt/log.h>
+#include <xbt/str.h>
+
+#include <surf/surf_routing.h>
+
+#include <simgrid/s4u/host.hpp>
+
#include "simgrid/msg.h"
#include "jmsg.h"
#include "jmsg_host.h"
#include "jxbt_utilities.h"
#include "jmsg_storage.h"
-#include <surf/surf_routing.h>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
const char *jhost_get_name(jobject jhost, JNIEnv * env) {
msg_host_t host = jhost_get_native(env, jhost);
- return MSG_host_get_name(host);
+ return host->cname();
}
jboolean jhost_is_valid(jobject jhost, JNIEnv * env) {
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) {
- msg_host_t host; /* native host */
- jobject jhost; /* global reference to the java host instance returned */
/* get the C string from the java string */
if (jname == nullptr) {
}
const char *name = env->GetStringUTFChars(jname, 0);
/* get the host by name (the hosts are created during the grid resolution) */
- host = MSG_host_by_name(name);
+ msg_host_t host = MSG_host_by_name(name);
if (!host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
if (!host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
/* Instantiate a new java host */
- jhost = jhost_new_instance(env);
+ jobject jhost = jhost_new_instance(env);
if (!jhost) {
jxbt_throw_jni(env, "java host instantiation failed");
return nullptr;
}
/* Sets the host name */
- const char *name = MSG_host_get_name(host);
- jobject jname = env->NewStringUTF(name);
+ jobject jname = env->NewStringUTF(host->cname());
env->SetObjectField(jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
const char *value_java = env->GetStringUTFChars((jstring) jvalue, 0);
char *value = xbt_strdup(value_java);
- MSG_host_set_property_value(host, name, value, xbt_free_f);
+ MSG_host_set_property_value(host, name, value);
env->ReleaseStringUTFChars((jstring) jvalue, value_java);
env->ReleaseStringUTFChars((jstring) jname, name);
jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
if (!jhost) {
- jname = env->NewStringUTF(MSG_host_get_name(host));
+ jname = env->NewStringUTF(host->cname());
jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
/* FIXME: leak of jname ? */