Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Attempt to solve issues with our own finalize
[simgrid.git] / src / bindings / java / org / simgrid / msg / Semaphore.java
index d74a8bc..4f23563 100644 (file)
@@ -34,6 +34,7 @@ public class Semaphore {
        /** Locks on the semaphore object until the provided timeout expires
         * @exception TimeoutException if the timeout expired before 
         *            the semaphore could be acquired.
+        * @param timeout the duration of the lock
         */
        public native void acquire(double timeout) throws TimeoutException;
        /** Locks on the semaphore object with no timeout
@@ -42,8 +43,8 @@ public class Semaphore {
                try {
                        acquire(-1);
                } catch (TimeoutException e) {
-                       // This should not happen.
-                       assert(false);
+                       e.printStackTrace(); // This should not happen.
+                       assert false ;
                }
        }
        /** Releases the semaphore object
@@ -65,20 +66,17 @@ public class Semaphore {
        }
 
 
-       /** Deletes this semaphore 
-        */
-       protected void finalize() {
-               destroy();
+       /** Deletes this semaphore when the GC reclaims it */
+       protected void finalize() throws Throwable {
+               nativeFinalize();
        }
-       /** The native implementation for destroying a semaphore
-        */
-       private native void destroy();
+       private native void nativeFinalize();
        /**
         * Class initializer, to initialize various JNI stuff
         */
        public static native void nativeInit();
        static {
-               Msg.nativeInit();
+               org.simgrid.NativeLib.nativeInit();
                nativeInit();
        }
 }
\ No newline at end of file