X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3471c603835f009fefcd5c660cf315f323863188..5ed37babb2fa9097abe82df299c0aa259ed84d5a:/src/bindings/java/jmsg_vm.cpp diff --git a/src/bindings/java/jmsg_vm.cpp b/src/bindings/java/jmsg_vm.cpp index ecb41ca667..a9174bacfa 100644 --- a/src/bindings/java/jmsg_vm.cpp +++ b/src/bindings/java/jmsg_vm.cpp @@ -1,6 +1,6 @@ /* Functions related to the Virtual Machines. */ -/* Copyright (c) 2012-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2012-2023. 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. */ @@ -10,8 +10,7 @@ #include "jxbt_utilities.hpp" #include "simgrid/Exception.hpp" #include "simgrid/plugins/live_migration.h" -#include "src/kernel/context/Context.hpp" -#include "src/plugins/vm/VirtualMachineImpl.hpp" +#include "src/kernel/resource/VirtualMachineImpl.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java); @@ -71,10 +70,9 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jVm, { sg_host_t host = jhost_get_native(env, jHost); - const char* name = env->GetStringUTFChars(jname, nullptr); + jstring_wrapper name(env, jname); sg_vm_t vm = sg_vm_create_migratable(host, name, static_cast(coreAmount), static_cast(jramsize), static_cast(jmig_netspeed), static_cast(jdp_intensity)); - env->ReleaseStringUTFChars(jname, name); jvm_bind(env, jVm, vm); jVm = env->NewGlobalRef(jVm); @@ -141,7 +139,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_destroy(JNIEnv* env, jobject jvm) sg_vm_t vm = jvm_get_native(env, jvm); if (vm) { sg_vm_destroy(vm); - auto* vmList = &simgrid::vm::VirtualMachineImpl::allVms_; + auto* vmList = &simgrid::kernel::resource::VirtualMachineImpl::allVms_; vmList->erase(std::remove(vmList->begin(), vmList->end(), vm), vmList->end()); } } @@ -152,7 +150,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeMigration(JNIEnv* env, jobj sg_host_t host = jhost_get_native(env, jhost); if (not simgrid::ForcefulKillException::try_n_catch([&vm, &host]() { sg_vm_migrate(vm, host); })) { XBT_VERB("Caught exception during migration"); - jxbt_throw_host_failure(env, "during migration"); + jxbt_throw_host_failure(env, " during migration"); } } @@ -175,16 +173,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclas jxbt_throw_null(env, "No VM can have a null name"); return nullptr; } - const char* name = env->GetStringUTFChars(jname, nullptr); + jstring_wrapper name(env, jname); /* get the VM by name (VMs are just special hosts, unfortunately) */ auto const* host = sg_host_by_name(name); if (not host) { /* invalid name */ jxbt_throw_host_not_found(env, name); - env->ReleaseStringUTFChars(jname, name); return nullptr; } - env->ReleaseStringUTFChars(jname, name); return static_cast(host->extension(JAVA_HOST_LEVEL)); }