/* Java Wrappers to the MSG API. */
-/* 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. */
int JAVA_HOST_LEVEL = -1;
int JAVA_STORAGE_LEVEL = -1;
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
JavaVM *__java_vm = nullptr;
JNIEnv *get_current_thread_env()
{
- JNIEnv *env;
-
- __java_vm->AttachCurrentThread((void **) &env, nullptr);
- return env;
+ using simgrid::kernel::context::JavaContext;
+ JavaContext* ctx = static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
+ return ctx->jenv;
}
void jmsg_throw_status(JNIEnv *env, msg_error_t status) {
jstring jval;
const char *tmp;
- XBT_LOG_CONNECT(jmsg);
+ XBT_LOG_CONNECT(java);
XBT_LOG_CONNECT(jtrace);
env->GetJavaVM(&__java_vm);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls)
{
msg_netzone_t as = MSG_environment_get_routing_root();
- jobject jas = jas_new_instance(env);
+ jobject jas = jnetzone_new_instance(env);
if (!jas) {
jxbt_throw_jni(env, "java As instantiation failed");
return nullptr;
}
- jas = jas_ref(env, jas);
+ jas = jnetzone_ref(env, jas);
if (!jas) {
jxbt_throw_jni(env, "new global ref allocation failed");
return nullptr;
}
- jas_bind(jas, as, env);
+ jnetzone_bind(jas, as, env);
return (jobject) jas;
}