Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Attempt to solve issues with our own finalize
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 29 Jun 2016 09:20:21 +0000 (11:20 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 29 Jun 2016 09:20:21 +0000 (11:20 +0200)
follow syntax from the java in a nutshell book

src/bindings/java/org/simgrid/msg/Comm.java
src/bindings/java/org/simgrid/msg/Mutex.java
src/bindings/java/org/simgrid/msg/RngStream.java
src/bindings/java/org/simgrid/msg/Semaphore.java
src/bindings/java/org/simgrid/msg/Task.java

index 8d07c51..29c5587 100644 (file)
@@ -33,13 +33,8 @@ public class Comm {
 
        }
        /** Destroy the C communication object, when the GC reclaims the java part. */
-       @Override
-       protected void finalize() {
-               try {
-                       nativeFinalize();
-               } catch (Throwable e) {
-                       e.printStackTrace();
-               }
+       protected void finalize() throws Throwable{
+               nativeFinalize();
        }
        protected native void nativeFinalize();
        /**
index d670f55..80f013b 100644 (file)
@@ -17,13 +17,9 @@ public class Mutex {
        public Mutex() {
                init();
        }
-       @Override
-       protected void finalize() {
-               try {
-                       nativeFinalize();
-               } catch (Throwable e) {
-                       e.printStackTrace();
-               }
+
+       protected void finalize() throws Throwable{
+               nativeFinalize();
        }
        private native void nativeFinalize();
        private native void init();
index 7e6fecc..e286c4a 100644 (file)
@@ -41,13 +41,9 @@ public class RngStream {
         * The natively implemented method to create a C RngStream object.
         */
        private native void create(String name);
-       @Override
-       protected void finalize() {
-               try {
-                       nativeFinalize();
-               } catch (Throwable e) {
-                       e.printStackTrace();
-               }
+
+       protected void finalize() throws Throwable{
+               nativeFinalize();
        }
        /**
         * Release the C RngStream object
index 4952184..4f23563 100644 (file)
@@ -67,13 +67,8 @@ public class Semaphore {
 
 
        /** Deletes this semaphore when the GC reclaims it */
-       @Override
-       protected void finalize() {
-               try {
-                       nativeFinalize();
-               } catch (Throwable e) {
-                       e.printStackTrace();
-               }
+       protected void finalize() throws Throwable {
+               nativeFinalize();
        }
        private native void nativeFinalize();
        /**
index bd9bf7b..26dc2b0 100644 (file)
@@ -167,16 +167,9 @@ public class Task {
        public native void cancel();
 
        /** Deletes a task once the garbage collector reclaims it */
-       @Override
-       protected void finalize() {
-               try {
-                       // Exceptions in finalizers lead to bad situations:
-                       // http://stackoverflow.com/questions/7644556/troubleshooting-a-java-memory-leak-finalization
-                       nativeFinalize();
-                       bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize()
-               } catch (Throwable e) {
-                       e.printStackTrace();
-               }
+       protected void finalize() throws Throwable{
+               nativeFinalize();
+               bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize()
        }
        protected native void nativeFinalize();
        /* *                       * *