Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please clang (?) and make properties optional to create an ActorImpl
[simgrid.git] / src / bindings / java / jmsg_process.cpp
index 11afaf7..8144317 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java process instances.                         */
 
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. 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. */
@@ -70,26 +70,24 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv* env, jobject
   jobject jprocess = jprocess_ref(jprocess_arg, env);
 
   /* Actually build the MSG process */
-  jstring jname     = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
-  const char* name  = env->GetStringUTFChars(jname, 0);
+  auto jname        = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
+  const char* name  = env->GetStringUTFChars(jname, nullptr);
   auto actor_code   = [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); };
   smx_actor_t self  = SIMIX_process_self();
   sg_host_t host    = jhost_get_native(env, jhost);
   smx_actor_t actor = simgrid::kernel::actor::simcall([name, actor_code, host, self] {
-    return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, nullptr,
-                                                     self)
-        .get();
+    return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, self).get();
   });
   sg_actor_yield();
 
   env->ReleaseStringUTFChars(jname, name);
 
   /* Retrieve the kill time from the actor */
-  actor->ciface()->set_kill_time((double)env->GetDoubleField(jprocess, jprocess_field_Process_killTime));
+  actor->get_ciface()->set_kill_time((double)env->GetDoubleField(jprocess, jprocess_field_Process_killTime));
 
   /* sets the PID and the PPID of the actor */
-  env->SetIntField(jprocess, jprocess_field_Process_pid, (jint)actor->ciface()->get_pid());
-  env->SetIntField(jprocess, jprocess_field_Process_ppid, (jint)actor->ciface()->get_ppid());
+  env->SetIntField(jprocess, jprocess_field_Process_pid, (jint)actor->get_ciface()->get_pid());
+  env->SetIntField(jprocess, jprocess_field_Process_ppid, (jint)actor->get_ciface()->get_ppid());
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_daemonize(JNIEnv* env, jobject jprocess)
@@ -111,7 +109,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_killAll(JNIEnv* env, jclass
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jclass cls, jint pid)
 {
-  auto const* actor = sg_actor_by_PID(pid);
+  auto const* actor = sg_actor_by_pid(pid);
 
   if (not actor) {
     jxbt_throw_process_not_found(env, std::string("PID = ") + std::to_string(static_cast<int>(pid)));
@@ -131,7 +129,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_nativeGetPID(JNIEnv* env, jobject jprocess)
 {
   const_sg_actor_t actor = jprocess_to_native(jprocess, env);
-  return sg_actor_get_PID(actor);
+  return sg_actor_get_pid(actor);
 }
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
@@ -141,7 +139,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env,
     jxbt_throw_notbound(env, "process", jprocess);
     return nullptr;
   }
-  const char *name = env->GetStringUTFChars((jstring)jname, 0);
+  const char* name = env->GetStringUTFChars((jstring)jname, nullptr);
 
   const char* property = actor->get_property(name);
   if (not property)