Merge: More tweaks to support the Java FFI on turing
authorJean Privat <jean@pryen.org>
Wed, 12 Nov 2014 19:10:06 +0000 (14:10 -0500)
committerJean Privat <jean@pryen.org>
Wed, 12 Nov 2014 19:10:06 +0000 (14:10 -0500)
Pull-Request: #903
Reviewed-by: Jean Privat <jean@pryen.org>

lib/java/java.nit
src/ffi/java.nit
tests/sav/test_ffi_java_types.res
tests/test_ffi_java_types.nit
tests/tests.sh

index 389c6f6..0b6a652 100644 (file)
@@ -27,7 +27,7 @@
 # most of JNI functions. You can use it to further customize the behavior
 # of your code.
 module java is
-       c_compiler_option("-I $(JAVA_HOME)/include/")
+       c_compiler_option "-I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/"
        c_linker_option("-L $(JNI_LIB_PATH) -ljvm")
        new_annotation extra_java_files
 end
index fa3cc84..9191141 100644 (file)
@@ -242,7 +242,7 @@ redef class MModule
        # Tell the C compiler where to find jni.h and how to link with libjvm
        private fun insert_compiler_options
        do
-               c_compiler_options = "{c_compiler_options} -I $(JAVA_HOME)/include/"
+               c_compiler_options = "{c_compiler_options} -I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/"
                c_linker_options = "{c_linker_options} -L $(JNI_LIB_PATH) -ljvm"
        end
 
index 642abeb..19ca640 100644 (file)
@@ -27,11 +27,11 @@ extern class JavaArrayList in "Java" `{ java.util.ArrayList `}
                return new ArrayList();
        `}
 
-       fun add(o: Int) in "Java" `{ recv.add(o); `}
+       fun add(o: JavaString) in "Java" `{ recv.add(o); `}
 
        redef fun output in "Java" `{
                for (Object i: recv) {
-                       System.out.println((long)i);
+                       System.out.println((String)i);
                }
        `}
 
@@ -41,12 +41,12 @@ extern class JavaArrayList in "Java" `{ java.util.ArrayList `}
 end
 
 var ll = new JavaArrayList
-ll.add(1)
-ll.add(2)
-ll.add(1)
-ll.add(3)
-ll.add(20)
-ll.add(10)
+ll.add "1".to_java_string
+ll.add "2".to_java_string
+ll.add "1".to_java_string
+ll.add "3".to_java_string
+ll.add "20".to_java_string
+ll.add "10".to_java_string
 ll.output
 ll.sort
 ll.output
index 09eb300..faed626 100755 (executable)
@@ -27,13 +27,13 @@ unset NIT_DIR
 
 # Get the first Java lib available
 shopt -s nullglob
-paths=`echo /usr/lib/jvm/*/`
-paths=($paths) 
-JAVA_HOME=${paths[0]}
+JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
 
 paths=`echo $JAVA_HOME/jre/lib/*/{client,server}/`
 paths=($paths) 
 JNI_LIB_PATH=${paths[0]}
+echo $JAVA_HOME
+echo $JNI_LIB_PATH
 shopt -u nullglob
 
 outdir="out"