X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7f4f03348bd07609e258eb3b545bdafc2c881847..7b138f8b1ed3e8816eda5cb26deb71fe81b4087a:/src/bindings/java/jmsg_synchro.cpp diff --git a/src/bindings/java/jmsg_synchro.cpp b/src/bindings/java/jmsg_synchro.cpp index b8791b470e..0ae09a7066 100644 --- a/src/bindings/java/jmsg_synchro.cpp +++ b/src/bindings/java/jmsg_synchro.cpp @@ -15,44 +15,37 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg); static jfieldID jsyncro_field_Mutex_bind; -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Mutex_nativeInit(JNIEnv *env, jclass cls) { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeInit(JNIEnv *env, jclass cls) { jsyncro_field_Mutex_bind = jxbt_get_sfield(env, "org/simgrid/msg/Mutex", "bind", "J"); if (!jsyncro_field_Mutex_bind) { jxbt_throw_native(env,bprintf("Can't find some fields in Java class. You should report this bug.")); } } -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Mutex_init(JNIEnv * env, jobject obj) { + +JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_init(JNIEnv * env, jobject obj) { xbt_mutex_t mutex = xbt_mutex_init(); env->SetLongField(obj, jsyncro_field_Mutex_bind, (jlong) (uintptr_t) (mutex)); } -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Mutex_acquire(JNIEnv * env, jobject obj) { - xbt_mutex_t mutex; - - mutex = (xbt_mutex_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Mutex_bind); - xbt_ex_t e; - TRY { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_acquire(JNIEnv * env, jobject obj) { + xbt_mutex_t mutex = (xbt_mutex_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Mutex_bind); + try { xbt_mutex_acquire(mutex); } - CATCH(e) { - xbt_ex_free(e); + catch(xbt_ex& e) { + // Nothing to do } } -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Mutex_release(JNIEnv * env, jobject obj) { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_release(JNIEnv * env, jobject obj) { xbt_mutex_t mutex; mutex = (xbt_mutex_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Mutex_bind); xbt_mutex_release(mutex); } -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) { xbt_mutex_t mutex; mutex = (xbt_mutex_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Mutex_bind); @@ -61,23 +54,20 @@ Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) { static jfieldID jsyncro_field_Semaphore_bind; -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Semaphore_nativeInit(JNIEnv *env, jclass cls) { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeInit(JNIEnv *env, jclass cls) { jsyncro_field_Semaphore_bind = jxbt_get_sfield(env, "org/simgrid/msg/Semaphore", "bind", "J"); if (!jsyncro_field_Semaphore_bind) { jxbt_throw_native(env,bprintf("Can't find some fields in Semaphore Java class. You should report this bug.")); } } -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Semaphore_init(JNIEnv * env, jobject obj, jint capacity) { + +JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_init(JNIEnv * env, jobject obj, jint capacity) { msg_sem_t sem = MSG_sem_init((int) capacity); env->SetLongField(obj, jsyncro_field_Semaphore_bind, (jlong) (uintptr_t) (sem)); } - -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Semaphore_acquire(JNIEnv * env, jobject obj, jdouble timeout) { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_acquire(JNIEnv * env, jobject obj, jdouble timeout) { msg_sem_t sem; sem = (msg_sem_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Semaphore_bind); @@ -87,15 +77,14 @@ Java_org_simgrid_msg_Semaphore_acquire(JNIEnv * env, jobject obj, jdouble timeou } } -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Semaphore_release(JNIEnv * env, jobject obj) { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_release(JNIEnv * env, jobject obj) { msg_sem_t sem; sem = (msg_sem_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Semaphore_bind); MSG_sem_release(sem); } -JNIEXPORT jboolean JNICALL -Java_org_simgrid_msg_Semaphore_wouldBlock(JNIEnv * env, jobject obj) { + +JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Semaphore_wouldBlock(JNIEnv * env, jobject obj) { msg_sem_t sem; sem = (msg_sem_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Semaphore_bind); @@ -103,8 +92,7 @@ Java_org_simgrid_msg_Semaphore_wouldBlock(JNIEnv * env, jobject obj) { return (jboolean) res; } -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Semaphore_nativeFinalize(JNIEnv * env, jobject obj) { +JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeFinalize(JNIEnv * env, jobject obj) { msg_sem_t sem; sem = (msg_sem_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Semaphore_bind);