+ for (int i=0; i < *count; i++) {
+ jobject jcomm = env->GetObjectArrayElement(jcomms, i);
+ if (env->ExceptionOccurred())
+ break;
+
+ comms[i] = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
+ if (!comms[i]) {
+ jxbt_throw_null(env, bprintf("comm at rank %d is null", i));
+ return nullptr;
+ }
+
+ env->DeleteLocalRef(jcomm); // reduce the load on the garbage collector: we don't need that object anymore
+ }
+ return comms;
+}
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAll(JNIEnv *env, jclass cls, jobjectArray jcomms, jdouble timeout)
+{
+ int count;
+ msg_comm_t* comms = jarray_to_commArray(env, jcomms, &count);
+ if (!comms)
+ return;
+
+ MSG_comm_waitall(comms, count, static_cast<double>(timeout));
+ xbt_free(comms);