Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference local variables in src/bindings/.
[simgrid.git] / src / bindings / java / jmsg.cpp
index ebe9597..15f74c1 100644 (file)
@@ -52,7 +52,7 @@ JavaVM *__java_vm = nullptr;
 JNIEnv *get_current_thread_env()
 {
   using simgrid::kernel::context::JavaContext;
-  JavaContext* ctx = static_cast<JavaContext*>(simgrid::kernel::context::Context::self());
+  const JavaContext* ctx = static_cast<JavaContext*>(simgrid::kernel::context::Context::self());
   if (ctx)
     return ctx->jenv_;
   else
@@ -92,7 +92,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, j
   env->GetJavaVM(&__java_vm);
 
   simgrid::kernel::context::factory_initializer = &simgrid::kernel::context::java_factory;
-  jthrowable exc = env->ExceptionOccurred();
+  const _jthrowable* exc                        = env->ExceptionOccurred();
   if (exc) {
     env->ExceptionClear();
   }
@@ -104,7 +104,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, j
     argc += static_cast<int>(env->GetArrayLength(jargs));
   xbt_assert(argc > 0);
 
-  // Need a static storage because the XBT layer saves the arguments in xbt_binary_name and xbt_cmdline.
+  // Need a static storage because the XBT layer saves the arguments in xbt::binary_name and xbt::cmdline.
   static std::vector<std::string> args;
   args.reserve(argc);
 
@@ -144,7 +144,7 @@ JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass
   /* Cleanup java hosts */
   xbt_dynar_t hosts = MSG_hosts_as_dynar();
   for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
-    msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);
+    auto const* msg_host = xbt_dynar_get_as(hosts, index, msg_host_t);
     jobject jhost = (jobject) msg_host->extension(JAVA_HOST_LEVEL);
     if (jhost)
       jhost_unref(env, jhost);
@@ -238,7 +238,7 @@ Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, jstring jde
 {
   const char *deploymentFile = env->GetStringUTFChars(jdeploymentFile, 0);
 
-  SIMIX_function_register_default(java_main);
+  simgrid_register_default(java_main);
   MSG_launch_application(deploymentFile);
 }