Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 29 Jun 2016 09:22:40 +0000 (11:22 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 29 Jun 2016 09:22:40 +0000 (11:22 +0200)
src/bindings/java/org/simgrid/msg/Comm.java
src/bindings/java/org/simgrid/msg/File.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
src/simix/simcalls.py

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 e37b1f4..23283cf 100644 (file)
@@ -23,10 +23,7 @@ public class File {
        public File(String path) {
                open(path);
        }
-       @Override
-       protected void finalize() {
 
-       }
        /**
         * Opens the file whose name is the string pointed to by path.  
         * @param path is the file location on the storage
@@ -35,13 +32,16 @@ public class File {
        /**
         * Read elements of a file. 
         * @param size of each element
-        * @param nMemb is the number of elements of data to write 
+        * @param nMemb is the number of elements of data to write
+        * @return the actually read size
         */
        public native long read(long size, long nMemb);
+
        /**
         * Write elements into a file. 
         * @param size of each element  
         * @param nMemb is the number of elements of data to write 
+        * @return the actually written size
         */
        public native long write(long size, long nMemb);
        /**
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();
        /* *                       * *
index 7d1b2b7..9d51800 100755 (executable)
@@ -36,7 +36,7 @@ class Simcall(object):
         # libsmx.c  simcall_BODY_
         if self.simcalls_BODY is None:
             f = open('libsmx.cpp')
-            self.simcalls_BODY = set(re.findall('simcall_BODY_(.*?)\(', f.read()))
+            self.simcalls_BODY = set(re.findall(r'simcall_BODY_(.*?)\(', f.read()))
             f.close()
         if self.name not in self.simcalls_BODY:
             print ('# ERROR: No function calling simcall_BODY_%s' % self.name)
@@ -53,7 +53,7 @@ class Simcall(object):
             self.simcalls_PRE = set()
             for fn in glob.glob('smx_*') + glob.glob('../mc/*'):
                 f = open(fn)
-                self.simcalls_PRE |= set(re.findall('simcall_HANDLER_(.*?)\(', f.read()))
+                self.simcalls_PRE |= set(re.findall(r'simcall_HANDLER_(.*?)\(', f.read()))
                 f.close()
         if self.need_handler:
             if self.name not in self.simcalls_PRE:
@@ -174,10 +174,10 @@ def parse(fn):
         assert match, line
         ret, name, args, attrs = match.groups()
         sargs = []
-        if not re.match("^\s*$", args):
+        if not re.match(r"^\s*$", args):
             for arg in re.split(",", args):
                 args = args.strip()
-                match = re.match("^(.*?)\s*?(\S+)$", arg)
+                match = re.match(r"^(.*?)\s*?(\S+)$", arg)
                 t, n = match.groups()
                 t = t.strip()
                 n = n.strip()