Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change the File java API according to the changes in the C api
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Wed, 13 Jun 2012 13:33:47 +0000 (15:33 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Wed, 13 Jun 2012 13:33:47 +0000 (15:33 +0200)
examples/io/Node.java
org/simgrid/msg/File.java
src/jmsg_file.c
src/jmsg_file.h
src/jmsg_vm.c

index 5afc600..a0e1f95 100644 (file)
@@ -47,13 +47,13 @@ public class Node extends Process {
                Msg.info("Open file " + filename);
                File file = new File(mount,filename, "rw");
 
-               long read = file.read(mount,10000000,1);
+               long read = file.read(10000000,1);
                Msg.info("Having read " + read + " on " + filename);
                
-               long write = file.read(mount,100000,1);
+               long write = file.read(100000,1);
                Msg.info("Having write " + write + " on " + filename);
 
-               read = file.read(mount,10000000,1);
+               read = file.read(10000000,1);
                Msg.info("Having read " + read + " on " + filename);            
        }
 }
\ No newline at end of file
index d5af208..fa42c6d 100644 (file)
@@ -27,7 +27,7 @@ public class File {
                open(storage, path, mode);
        }
        protected void finalize() {
-               close(storage);
+
        }
        /**
         * Opens the file whose name is the string pointed to by path. 
@@ -42,19 +42,19 @@ public class File {
         * @param size of each element
         * @param nMemb is the number of elements of data to write 
         */
-       public native long read(String storage, long size, long nMemb);
+       public native long read(long size, long nMemb);
        /**
         * Write elements into a file. 
         * @param storage is the name where you can find the stream 
         * @param size of each element  
         * @param nMemb is the number of elements of data to write 
         */
-       public native long write(String storage, long size, long nMemb);
+       public native long write(long size, long nMemb);
        /**
         * Close the file.      
         * @param storage is the name where you can find the stream 
         */
-       public native void close(String storage);
+       public native void close();
        
        /**
         * Class initializer, to initialize various JNI stuff
index 3695fb8..2b5866d 100644 (file)
@@ -37,40 +37,27 @@ Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jstorage, job
        (*env)->ReleaseStringUTFChars(env, jmode, mode);
 }
 JNIEXPORT jlong JNICALL
-Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jobject jstorage, jlong jsize, jlong jnmemb) {
+Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) {
        msg_file_t file = jfile_get_native(env, jfile);
 
-       const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
-
-       size_t n = MSG_file_read(storage, NULL,(size_t)jsize, (size_t)jnmemb, file);
-
-       (*env)->ReleaseStringUTFChars(env, jstorage, storage);
+       size_t n = MSG_file_read(NULL,(size_t)jsize, (size_t)jnmemb, file);
 
        return (jlong)n;
 }
 
 JNIEXPORT jlong JNICALL
-Java_org_simgrid_msg_File_write(JNIEnv *env, jobject jfile, jobject jstorage, jlong jsize, jlong jnmemb) {
+Java_org_simgrid_msg_File_write(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) {
        msg_file_t file = jfile_get_native(env, jfile);
 
-       const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
-
-       size_t n = MSG_file_write(storage, NULL, (size_t)jsize, (size_t)jnmemb, file);
-
-       (*env)->ReleaseStringUTFChars(env, jstorage, storage);
+       size_t n = MSG_file_write(NULL, (size_t)jsize, (size_t)jnmemb, file);
 
        return (jlong)n;
 }
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfile, jobject jstorage) {
+Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfile) {
        msg_file_t file = jfile_get_native(env, jfile);
 
-       const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
-
-       MSG_file_close(storage, file);
+       MSG_file_close(file);
        jfile_bind(env, jfile, NULL);
-
-       (*env)->ReleaseStringUTFChars(env, jstorage, storage);
-
 }
 
index 4202ea2..2f554f6 100644 (file)
@@ -33,18 +33,18 @@ Java_org_simgrid_msg_File_open(JNIEnv*, jobject, jobject, jobject, jobject);
  * Method                      read
  */
 JNIEXPORT jlong JNICALL
-Java_org_simgrid_msg_File_read(JNIEnv*, jobject, jobject, jlong, jlong);
+Java_org_simgrid_msg_File_read(JNIEnv*, jobject, jlong, jlong);
 /**
  * Class                       org_simgrid_msg_File
  * Method                      write
  */
 JNIEXPORT jlong JNICALL
-Java_org_simgrid_msg_File_write(JNIEnv*, jobject, jobject, jlong, jlong);
+Java_org_simgrid_msg_File_write(JNIEnv*, jobject, jlong, jlong);
 /**
  * Class                       org_simgrid_msg_File
  * Method                      close
  */
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_File_close(JNIEnv*, jobject, jobject);
+Java_org_simgrid_msg_File_close(JNIEnv*, jobject);
 
 #endif
index f36a9f7..38e4cca 100644 (file)
@@ -23,7 +23,7 @@ JNIEXPORT void JNICALL
 Java_org_simgrid_msg_VM_nativeInit(JNIEnv *env, jclass cls) {
        jclass jprocess_class_VM = (*env)->FindClass(env, "org/simgrid/msg/VM");
        jvm_field_bind = jxbt_get_jfield(env, jprocess_class_VM, "bind", "J");
-       if (!jvm_field_bind) {
+       if (!jvm_field_bind     ) {
        jxbt_throw_native(env,bprintf("Can't find some fields in Java class. You should report this bug."));
        }
 }