Commits

camlspotter committed cad8b7b Draft

pushed camljava-0.3 of ubuntu

  • Participants
  • Parent commits 64c6a4b
  • Branches debian

Comments (0)

Files changed (21)

File camljava-0.3/Makefile

 all:
 	cd lib; $(MAKE) all
-
-opt:
-	cd lib; $(MAKE) opt
+byte:
+	cd lib; $(MAKE) byte
 
 install:
 	cd lib; $(MAKE) install

File camljava-0.3/Makefile.config

 ## For other platforms, adjust as required and tell us about it.
 
 # Home location for the JDK.  Only used for setting other variables below. 
-JDKHOME=/usr/lib/jvm/java-6-openjdk-i386
+JDKHOME=/usr/lib/jvm/java-6-sun
+
+# Current architecture identification string, as intended by the JDK.
+# Common values for x86 architectures are "i386" or "amd64". You can find it
+# out by looking for the "*" patch component in the following pattern:
+# $(JDKHOME)/jre/lib/*/libjava.so
+ARCH=amd64
 
 # Where to find the JNI include files (for compiling the OCaml-JNI C stubs)
 JNIINCLUDES=-I$(JDKHOME)/include -I$(JDKHOME)/include/linux
 
 # The library to link with to get the JNI
-JNILIBS=-ljvm -ljava
+JNILIBS=-ljava
 
 # Additional link-time options to pass to $(CC) when linking with $(JNILIBS)
-JNILIBOPTS=-L$(JDKHOME)/jre/lib/i386/ -L$(JDKHOME)/jre/lib/i386/client \
-        -Wl,-rpath,$(JDKHOME)/jre/lib/i386/ \
-        -Wl,-rpath,$(JDKHOME)/jre/lib/i386/client \
-        -Wl,-rpath,$(JDKHOME)/jre/lib/i386/native_threads
+JNILIBOPTS=-L$(JDKHOME)/jre/lib/$(ARCH)/ \
+        -L$(JDKHOME)/jre/lib/$(ARCH)/server \
+        -Wl,-rpath,$(JDKHOME)/jre/lib/$(ARCH)/ \
+        -Wl,-rpath,$(JDKHOME)/jre/lib/$(ARCH)/server \
+        -Wl,-rpath,$(JDKHOME)/jre/lib/$(ARCH)/native_threads
 
 # Additional options when compiling the OCaml-JNI C stubs.
 # -DJDK122_LINUX_HACK works around a nasty thread-related bug of

File camljava-0.3/Makefile.config.mingw

-################### C compiler ########################
-
-# C compiler to use
-CC=gcc -mno-cygwin
-
-# Flags for $(CC)
-CFLAGS=-O -g -Wall -Wno-unused -mms-bitfields
-
-################### Java compiler #####################
-
-# Java compiler to use
-JAVAC=javac -g
-
-################### JNI interface #####################
-
-## Defaults are set for Sun's JDK 1.2.2 under Linux.  
-## For other platforms, adjust as required and tell us about it.
-
-# Home location for the JDK.  Only used for setting other variables below. 
-JDKHOME=C:/Program\ Files/Java/j2sdk1.4.2_04
-
-# Where to find the JNI include files (for compiling the OCaml-JNI C stubs)
-JNIINCLUDES=-I$(JDKHOME)/include -I$(JDKHOME)/include/win32
-
-# The library to link with to get the JNI
-JNILIBS=-ljvm
-JNIPATH=$(JDKHOME)/jre/bin/client/jvm.dll
-
-# Additional link-time options to pass to $(CC) when linking with $(JNILIBS)
-JNILIBOPTS=-Wl,-rpath,`ocamlc -where`/camljava
-	
-
-JNISTUBSOPTIONS=

File camljava-0.3/Makefile.config.msvc

 ################### Java compiler #####################
 
 # Java compiler to use
-JAVAC=javac
+JAVAC=javac -g
 
 ################### JNI interface #####################
 

File camljava-0.3/Makefile.config.osx

-################### C compiler ########################
-
-# C compiler to use
-CC=gcc
-
-# Flags for $(CC)
-CFLAGS=-O -Wall
-
-################### Java compiler #####################
-
-# Java compiler to use
-JAVAC=javac
-
-################### JNI interface #####################
-
-## Defaults are set for MacOS X 10.2
-
-# Where to find the JNI include files (for compiling the OCaml-JNI C stubs)
-JNIINCLUDES=-I/System/Library/Frameworks/JavaVM.framework/Versions/CurrenCurrentt/Headers
-
-# The library to link with to get the JNI
-JNILIBS=-framework JavaVM
-
-# Additional link-time options to pass to $(CC) when linking with $(JNILIBS)
-JNILIBOPTS=

File camljava-0.3/Makefile.mingw

-MK=$(MAKE) -f Makefile.mingw
-
-all:
-	cd lib; $(MK) all
-
-opt:
-	cd lib; $(MK) opt
-
-install:
-	cd lib; $(MK) install
-
-tst:
-	cd test; $(MK) 
-
-clean:
-	cd lib; $(MK)  clean
-	cd test; $(MK) clean

File camljava-0.3/Makefile.msvc

 all:
 	cd lib; $(MK) all
 
-opt:
-	cd lib; $(MK) opt
-
 install:
 	cd lib; $(MK) install
 

File camljava-0.3/Makefile.osx

-MK=$(MAKE) -f Makefile.osx
-
-all:
-	cd lib; $(MK) all
-
-opt:
-	cd lib; $(MK) opt
-
-install:
-	cd lib; $(MK) install
-
-tst:
-	cd test; $(MK)
-
-clean:
-	cd lib; $(MK) clean
-	cd test; $(MK) clean

File camljava-0.3/lib/META

-name="camljava"
-version="0.3"
-description="an OCaml/Java interface"
-requires=""
-archive(byte)="jni.cma"
-archive(native)="jni.cmxa"
-linkopts = ""

File camljava-0.3/lib/Makefile

 OCAMLOPT=ocamlopt
 OCAMLDEP=ocamldep
 OCAMLLIB=`ocamlc -where`
-CAMLJAVALIB=$(shell ocamlfind printconf destdir)/camljava
+CAMLJAVALIB=$(OCAMLLIB)/camljava
 
-all: jni.cma javaclasses
-opt: jni.cmxa javaclasses
+all: jni.cma jni.cmxa javaclasses
+byte: jni.cma javaclasses
 
 install:
 	mkdir -p $(CAMLJAVALIB)
-	if test -f jni.cmxa; then cp jni.cmxa jni.a $(CAMLJAVALIB); fi
-	cp jni.cma jni.cmi libcamljni.a jni.mli $(CAMLJAVALIB)
+	cp jni.cma jni.cmi $(wildcard jni.cmxa jni.a) libcamljni.a jni.mli $(CAMLJAVALIB)
 	jar cf $(CAMLJAVALIB)/camljava.jar fr/inria/caml/camljava/*.class
-	cp ../Makefile.config $(CAMLJAVALIB)
-	ocamlfind install camljava META
 
 jni.cma: jni.cmo libcamljni.a
 	$(OCAMLC) -linkall -a -o jni.cma -custom jni.cmo \
 	rm -f fr/inria/caml/camljava/*.class
 
 clean::
-	rm -f *.cm? *.[oa]
+	rm -f *.cm? *.[oa] *.cmxa
 
 .SUFFIXES: .ml .mli .cmo .cmi .cmx
 

File camljava-0.3/lib/Makefile.mingw

-include ../Makefile.config.mingw
-
-OCAMLC=ocamlc -g
-OCAMLOPT=ocamlopt
-OCAMLDEP=ocamldep
-OCAMLLIB=`ocamlc -where`
-CAMLJAVALIB=$(OCAMLLIB)/camljava
-
-all: libjvm.dll.a jni.cma javaclasses
-opt: libjvm.dll.a jni.cmxa javaclasses
-
-install:
-	mkdir -p $(CAMLJAVALIB)
-	if test -f jni.cmxa; then cp jni.cmxa jni.a; fi
-	cp jni.cma jni.cmi libcamljni.a jni.mli libjvm.dll.a $(CAMLJAVALIB)
-	jar cf $(CAMLJAVALIB)/camljava.jar fr/inria/caml/camljava/*.class
-
-jni.cma: jni.cmo libcamljni.a
-	$(OCAMLC) -linkall -a -o jni.cma -custom jni.cmo \
-            -ccopt "$(JNILIBOPTS)" -cclib -lcamljni -cclib "$(JNILIBS)"
-
-jni.cmxa: jni.cmx libcamljni.a
-	$(OCAMLOPT) -linkall -a -o jni.cmxa jni.cmx \
-            -ccopt "$(JNILIBOPTS)" -cclib -lcamljni -cclib "$(JNILIBS)"
-
-libcamljni.a: jnistubs.o
-	rm -f libcamljni.a
-	ar rcs libcamljni.a jnistubs.o
-
-
-libjvm.dll.a: jvm.def
-	dlltool --input-def jvm.def --kill-at --dllname $(JNIPATH) --output-lib libjvm.dll.a
-
-clean::
-	rm -f libcamljni.a
-
-jni.ml: jni.mlp jni.mli ../Makefile.config
-	rm -f jni.ml
-	sed -e 's|%PATH%|'$(CAMLJAVALIB)/camljava.jar'|' \
-                jni.mlp > jni.ml
-	chmod -w jni.ml
-
-clean::
-	rm -f jni.ml
-
-beforedepend:: jni.ml
-
-javaclasses:
-	$(JAVAC) fr/inria/caml/camljava/*.java
-
-clean::
-	rm -f fr/inria/caml/camljava/*.class
-
-clean::
-	rm -f *.cm? *.[oa]
-
-.SUFFIXES: .ml .mli .cmo .cmi .cmx
-
-.c.o:
-	$(CC) -c $(CFLAGS) $(JNIINCLUDES) -I$(OCAMLLIB) $*.c
-
-.ml.cmo:
-	$(OCAMLC) -c $*.ml
-
-.ml.cmx:
-	$(OCAMLOPT) -c $*.ml
-
-.mli.cmi:
-	$(OCAMLC) -c $*.mli
-
-depend: beforedepend
-	$(OCAMLDEP) *.mli *.ml > .depend
-
-include .depend
-

File camljava-0.3/lib/Makefile.msvc

 OCAMLLIB=`ocamlc -where`
 CAMLJAVALIB=$(OCAMLLIB)/camljava
 
-all: jni.cma javaclasses
-opt: jni.cmxa javaclasses
+all: jni.cma jni.cmxa javaclasses
 
 install:
 	mkdir -p $(CAMLJAVALIB)
-	if test -f jni.cmxa; then cp jni.cmxa jni.lib $(CAMLJAVALIB); fi
-	cp jni.cma jni.cmi libcamljni.lib jni.mli $(CAMLJAVALIB)
+	cp jni.cma jni.cmi jni.cmxa jni.lib libcamljni.lib jni.mli $(CAMLJAVALIB)
 	jar cf $(CAMLJAVALIB)/camljava.jar fr/inria/caml/camljava/*.class
-	cp ../Makefile.config.msvc $(CAMLJAVALIB)/Makefile.config
 
 jni.cma: jni.cmo libcamljni.lib
 	$(OCAMLC) -linkall -a -o jni.cma -custom jni.cmo \

File camljava-0.3/lib/Makefile.osx

-include ../Makefile.config.osx
-
-OCAMLC=ocamlc.opt -g
-OCAMLOPT=ocamlopt
-OCAMLDEP=ocamldep
-OCAMLLIB=`ocamlc -where`
-CAMLJAVALIB=$(OCAMLLIB)/camljava
-
-all: jni.cma javaclasses
-opt: jni.cmxa javaclasses
-
-install:
-	mkdir -p $(CAMLJAVALIB)
-	if test -f jni.cmxa; then cp jni.cmxa jni.a $(CAMLJAVALIB); fi
-	cp jni.cma jni.cmi libcamljni.a jni.mli $(CAMLJAVALIB)
-	jar cf $(CAMLJAVALIB)/camljava.jar fr/inria/caml/camljava/*.class
-	ranlib $(CAMLJAVALIB)/libcamljni.a 
-	if test -f jni.a; then ranlib $(CAMLJAVALIB)/jni.a; fi
-	cp ../Makefile.config.osx $(CAMLJAVALIB)/Makefile.config
-
-jni.cma: jni.cmo libcamljni.a
-	$(OCAMLC) -linkall -a -o jni.cma -custom jni.cmo \
-            -ccopt "$(JNILIBOPTS)" -cclib -lcamljni -cclib "$(JNILIBS)"
-
-jni.cmxa: jni.cmx libcamljni.a
-	$(OCAMLOPT) -linkall -a -o jni.cmxa jni.cmx \
-            -ccopt "$(JNILIBOPTS)" -cclib -lcamljni -cclib "$(JNILIBS)"
-
-libcamljni.a: jnistubs.o
-	rm -f libcamljni.a
-	ar rcs libcamljni.a jnistubs.o
-
-clean::
-	rm -f libcamljni.a
-
-jni.ml: jni.mlp jni.mli ../Makefile.config
-	rm -f jni.ml
-	sed -e 's|%PATH%|'$(CAMLJAVALIB)/camljava.jar'|' \
-                jni.mlp > jni.ml
-	chmod -w jni.ml
-
-clean::
-	rm -f jni.ml
-
-beforedepend:: jni.ml
-
-javaclasses:
-	$(JAVAC) fr/inria/caml/camljava/*.java
-
-clean::
-	rm -f fr/inria/caml/camljava/*.class
-
-clean::
-	rm -f *.cm? *.[oa]
-
-.SUFFIXES: .ml .mli .cmo .cmi .cmx
-
-.c.o:
-	$(CC) -c $(CFLAGS) $(JNIINCLUDES) -I$(OCAMLLIB) $*.c
-
-.ml.cmo:
-	$(OCAMLC) -c $*.ml
-
-.ml.cmx:
-	$(OCAMLOPT) -c $*.ml
-
-.mli.cmi:
-	$(OCAMLC) -c $*.mli
-
-depend: beforedepend
-	$(OCAMLDEP) *.mli *.ml > .depend
-
-include .depend
-

File camljava-0.3/lib/jni.mli

 (*                                                                     *)
 (***********************************************************************)
 
-(* $Id: jni.mli,v 1.1.1.1 2004/07/19 11:10:24 henry Exp $ *)
+(* $Id: jni.mli,v 1.1 2001/06/05 12:19:55 xleroy Exp $ *)
 
 (* Low-level Java interface (JNI level) *)
 
+external set_debug: bool -> unit = "camljava_set_debug"
+
+external set_string_auto_conv: bool -> unit = "camljava_set_strconv"
+
 (* Object operations *)
 
 type obj

File camljava-0.3/lib/jni.mlp

 (*                                                                     *)
 (***********************************************************************)
 
-(* $Id: jni.mlp,v 1.1.1.1 2004/07/19 11:10:24 henry Exp $ *)
+(* $Id: jni.mlp,v 1.3 2003/02/20 13:42:40 xleroy Exp $ *)
 
 (* Low-level Java interface (JNI level) *)
 
+external set_debug: bool -> unit = "camljava_set_debug"
+
+external set_string_auto_conv: bool -> unit = "camljava_set_strconv"
+
 external init: string -> unit = "camljava_Init"
 external shutdown: unit -> unit = "camljava_Shutdown"
 
       "Unix" -> ":"
     | "Win32" -> ";"
     | _ -> assert false in
-  let path = libpath ^ sep ^ "." in
   let path =
     try
-      Sys.getenv "CLASSPATH" ^ sep ^ path
+      Sys.getenv "CLASSPATH" ^ sep ^ libpath
     with Not_found ->
-      path in
+      libpath in
   init path;
   at_exit shutdown
 

File camljava-0.3/lib/jnistubs.c

 #define Val_jboolean(b) ((b) == JNI_FALSE ? Val_false : Val_true)
 #define Jboolean_val(v) (Val_bool(v) ? JNI_TRUE : JNI_FALSE)
 
-/**********Threading *************/
+/********** Threading *************/
 
 static JNIEnv * g_jenv;
 
 
 void camljava_check_main_thread() {
   if(jenv != g_jenv) {
-    fprintf(stderr,"Pas de callback depuis un thread autre que le thread principal pour l'instant !!!\n");
+    fprintf(stderr, "CamlJava: callbacks from threads other than main are not allowed: ABORT.\n");
     fflush(stderr);
-    // lever une exception Java serait mieux    
+    // raise a Java exception would be better
     exit(2);
   }
   return;
 
 /*********** Reflecting Java exceptions as Caml exceptions *************/
 
+static int debug = 0;
+
+value camljava_set_debug(value v) {
+  debug = Bool_val(v);
+  return Val_unit;
+}
+
 static void check_java_exception(void)
 {
   jthrowable exn;
 
   exn = (*jenv)->ExceptionOccurred(jenv);
   if (exn != NULL) {
-#if 0
-    /* For debugging */
-    (*jenv)->ExceptionDescribe(jenv);
-#endif
+    if(debug) {
+      /* For debugging */
+      (*jenv)->ExceptionDescribe(jenv);
+    }
     (*jenv)->ExceptionClear(jenv);
     /* TODO: check Caml exception embedded into Java exception */
     if (camljava_raise_exception == NULL) {
   return alloc_jobject(jstr);
 }
 
+/* Automatically convert Java string to Caml string?
+   True by default; globally set to false by O'Jacare. */
+static int string_auto_conv = 1;
+
+value camljava_set_strconv(value v) {
+  string_auto_conv = Bool_val(v);
+  return Val_unit;
+}
+
 static value extract_java_string (JNIEnv * env, jstring jstr)
 {
   jsize len;
   retcode = JNI_CreateJavaVM(&jvm, (void **) &jenv, &vm_args);
   stat_free(classpath);
   if (retcode < 0) failwith("Java.init");
-  init_threading(); // Ajout O'Jacare
+  init_threading(); // by O'Jacare
   return Val_unit;
 }
 
 {
 #define INIT_CAML_CLASS(cls,fld,cname,fsig)                                 \
     cls = (*env)->FindClass(env, cname);                                    \
+    cls = (*env)->NewGlobalRef(env, cls);                                   \
     if (cls == NULL) return -1;                                             \
     fld = (*env)->GetFieldID(env, cls, "contents", fsig);                   \
     if (fld == NULL) return -1;
   savedenv = jenv;
   jenv = env;
 
-  camljava_check_main_thread(); // Ajout O'Jacare
+  camljava_check_main_thread(); // by O'Jacare
 
   if (!caml_classes_initialized) {
     if (init_caml_classes(env) == -1) return -1;
       else if ((*env)->IsInstanceOf(env, arg, caml_double))
         carg = copy_double((*env)->GetDoubleField(env, arg,
                                                 caml_double_contents));
-      /*      else if ((*env)->IsInstanceOf(env, arg, java_lang_string))
-	      carg = extract_java_string(env, (jstring) arg); */
+      else if (string_auto_conv
+	       && (*env)->IsInstanceOf(env, arg, java_lang_string))
+        carg = extract_java_string(env, (jstring) arg);
       else
         carg = alloc_jobject(arg);
       cargs[i] = carg;

File camljava-0.3/lib/jvm.def

-EXPORTS
-JNI_CreateJavaVM@12
-JNI_GetDefaultJavaVMInitArgs@4
-JNI_GetCreatedJavaVMs@12

File camljava-0.3/test/Makefile

 include ../Makefile.config
 
-CAMLJAVA=$(shell ocamlfind printconf destdir)/camljava/camljava.jar
+CAMLJAVA=`ocamlc -where`/camljava/camljava.jar
 
 all: jnitest Test.class Testcb.class
-	./jnitest
+	CLASSPATH=. ./jnitest
 
 jnitest: jnitest.ml
-	ocamlfind ocamlc -package camljava -g -o jnitest jni.cma jnitest.ml
+	ocamlc -ccopt -g -o jnitest -I +camljava jni.cma jnitest.ml
 
 clean::
 	rm -f jnitest
 	$(JAVAC) -classpath $(CAMLJAVA):. $*.java
 
 clean::
-	rm -f *.cm? *.class
+	rm -f *.cm?
+	rm -f *.class

File camljava-0.3/test/Makefile.mingw

-include ../Makefile.config.mingw
-
-CAMLJAVA=`ocamlc -where`/camljava/camljava.jar
-
-all: jnitest Test.class Testcb.class
-	./jnitest
-
-jnitest: jnitest.ml
-	ocamlc -ccopt -g -o jnitest -I +camljava jni.cma jnitest.ml 
-
-clean::
-	rm -f jnitest.exe
-
-.SUFFIXES: .java .class
-
-.java.class:
-	$(JAVAC) -classpath "$(CAMLJAVA);." $*.java
-
-clean::
-	rm -f *.cm? 

File camljava-0.3/test/Makefile.msvc

 	$(JAVAC) -classpath "$(CAMLJAVA);." $*.java
 
 clean::
-	rm -f *.cm? *.class
+	rm -f *.cm?

File camljava-0.3/test/Makefile.osx

-include ../Makefile.config.osx
-
-CAMLJAVA=`ocamlc -where`/camljava/camljava.jar
-
-all: jnitest Test.class Testcb.class
-	./jnitest
-
-jnitest: jnitest.ml
-	ocamlc -ccopt -g -o jnitest -I +camljava jni.cma jnitest.ml
-
-clean::
-	rm -f jnitest
-
-.SUFFIXES: .java .class
-
-.java.class:
-	$(JAVAC) -classpath $(CAMLJAVA):. $*.java
-
-clean::
-	rm -f *.cm? *.class