/* Functions related to the java host instances. */
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2017. 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 <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/plugins/energy.h"
+#include "simgrid/s4u/host.hpp"
-#include "simgrid/msg.h"
#include "jmsg.h"
#include "jmsg_host.h"
#include "jxbt_utilities.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
+SG_BEGIN_DECL()
+
static jmethodID jhost_method_Host_constructor;
static jfieldID jhost_field_Host_bind;
static jfieldID jhost_field_Host_name;
return (msg_host_t) (uintptr_t) env->GetLongField(jhost, jhost_field_Host_bind);
}
-const char *jhost_get_name(jobject jhost, JNIEnv * env) {
- msg_host_t host = jhost_get_native(env, jhost);
- return host->cname();
-}
-
-jboolean jhost_is_valid(jobject jhost, JNIEnv * env) {
- if (env->GetLongField(jhost, jhost_field_Host_bind)) {
- return JNI_TRUE;
- } else {
- return JNI_FALSE;
- }
-}
-
JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_nativeInit(JNIEnv *env, jclass cls) {
jclass class_Host = env->FindClass("org/simgrid/msg/Host");
jhost_method_Host_constructor = env->GetMethodID(class_Host, "<init>", "()V");
jhost_field_Host_bind = jxbt_get_jfield(env,class_Host, "bind", "J");
jhost_field_Host_name = jxbt_get_jfield(env, class_Host, "name", "Ljava/lang/String;");
- if (!class_Host || !jhost_field_Host_name || !jhost_method_Host_constructor || !jhost_field_Host_bind) {
- jxbt_throw_native(env,bprintf("Can't find some fields in Java class. You should report this bug."));
- }
+ xbt_assert(class_Host && jhost_field_Host_name && jhost_method_Host_constructor && jhost_field_Host_bind,
+ "Native initialization of msg/Host failed. Please report that bug");
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) {
env->ReleaseStringUTFChars((jstring) jname, name);
}
-#include "simgrid/plugins/energy.h"
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getConsumedEnergy (JNIEnv *env, jobject jhost)
{
msg_host_t host = jhost_get_native(env, jhost);
msg_host_t host = jhost_get_native(env, jhost);
return MSG_host_get_power_peak_at(host, pstate);
}
+
+SG_END_DECL()