/* 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. */
/* 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;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
JavaVM *__java_vm = nullptr;
int JAVA_HOST_LEVEL = -1;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
JavaVM *__java_vm = nullptr;
JNIEnv *get_current_thread_env()
{
using simgrid::kernel::context::JavaContext;
JavaContext* ctx = static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
JNIEnv *get_current_thread_env()
{
using simgrid::kernel::context::JavaContext;
JavaContext* ctx = static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
env->GetJavaVM(&__java_vm);
simgrid::kernel::context::factory_initializer = &simgrid::kernel::context::java_factory;
env->GetJavaVM(&__java_vm);
simgrid::kernel::context::factory_initializer = &simgrid::kernel::context::java_factory;
jxbt_check_res("MSG_main()", rv, MSG_OK,
xbt_strdup("unexpected error : MSG_main() failed .. please report this bug "));
jxbt_check_res("MSG_main()", rv, MSG_OK,
xbt_strdup("unexpected error : MSG_main() failed .. please report this bug "));
/* Cleanup java hosts */
xbt_dynar_t hosts = MSG_hosts_as_dynar();
for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
/* Cleanup java hosts */
xbt_dynar_t hosts = MSG_hosts_as_dynar();
for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
}
xbt_dynar_free(&hosts);
/* Cleanup java storages */
for (auto const& elm : java_storage_map)
jstorage_unref(env, elm.second);
}
xbt_dynar_free(&hosts);
/* Cleanup java storages */
for (auto const& elm : java_storage_map)
jstorage_unref(env, elm.second);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, jstring jplatformFile)
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, jstring jplatformFile)
jdouble startTime = env->GetDoubleField(jprocess, jprocess_field_Process_startTime);
if (startTime > MSG_get_clock())
MSG_process_sleep(startTime - MSG_get_clock());
jdouble startTime = env->GetDoubleField(jprocess, jprocess_field_Process_startTime);
if (startTime > MSG_get_clock())
MSG_process_sleep(startTime - MSG_get_clock());
//Execution of the "run" method.
jmethodID id = jxbt_get_smethod(env, "org/simgrid/msg/Process", "run", "()V");
//Execution of the "run" method.
jmethodID id = jxbt_get_smethod(env, "org/simgrid/msg/Process", "run", "()V");
for (int i = 1; i < argc; i++)
env->SetObjectArrayElement(args,i - 1, env->NewStringUTF(argv[i]));
//Retrieve the host for the process.
for (int i = 1; i < argc; i++)
env->SetObjectArrayElement(args,i - 1, env->NewStringUTF(argv[i]));
//Retrieve the host for the process.
jobject jhost = Java_org_simgrid_msg_Host_getByName(env, nullptr, jhostName);
//creates the process
jobject jprocess = env->NewObject(class_Process, constructor_Process, jhost, jname, args);
jobject jhost = Java_org_simgrid_msg_Host_getByName(env, nullptr, jhostName);
//creates the process
jobject jprocess = env->NewObject(class_Process, constructor_Process, jhost, jname, args);
/* sets the PID and the PPID of the process */
env->SetIntField(jprocess, jprocess_field_Process_pid, static_cast<jint>(MSG_process_get_PID(process)));
env->SetIntField(jprocess, jprocess_field_Process_ppid, static_cast<jint>(MSG_process_get_PPID(process)));
jprocess_bind(jprocess, process, env);
/* sets the PID and the PPID of the process */
env->SetIntField(jprocess, jprocess_field_Process_pid, static_cast<jint>(MSG_process_get_PID(process)));
env->SetIntField(jprocess, jprocess_field_Process_ppid, static_cast<jint>(MSG_process_get_PPID(process)));
jprocess_bind(jprocess, process, env);
{
JNIEnv *env = get_current_thread_env();
simgrid::kernel::context::JavaContext* context = static_cast<simgrid::kernel::context::JavaContext*>(SIMIX_context_self());
{
JNIEnv *env = get_current_thread_env();
simgrid::kernel::context::JavaContext* context = static_cast<simgrid::kernel::context::JavaContext*>(SIMIX_context_self());
- context->jprocess = jprocess;
- jprocess_bind(context->jprocess, MSG_process_self(), env);
+ context->jprocess_ = jprocess;
+ jprocess_bind(context->jprocess_, MSG_process_self(), env);