caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* CamlJava w/ recent OCaml (3.11.1) and Sun's JVM (OpenJDK)
@ 2009-11-23 15:55 Stefano Zacchiroli
  2009-11-24 14:00 ` [Caml-list] CamlJava - patch to *build* w/ recent JDK Stefano Zacchiroli
  2009-12-01 10:52 ` CamlJava w/ recent JVMs - solved (patches needed and included) Stefano Zacchiroli
  0 siblings, 2 replies; 3+ messages in thread
From: Stefano Zacchiroli @ 2009-11-23 15:55 UTC (permalink / raw)
  To: OCaml Mailing List; +Cc: Xavier Leroy

Has anyone successfully built/used CamlJava [1] with recent OCaml and
the open sourced Sun's JVM (OpenJDK)?  I've tried for a while, but I'm
stuck at the basics, i.e. making the example shipped with CamlJava work.

First of all there is some needed gymnastic to build: apparently there
is no longer _a_ legacy libjvm.so, but several one depending on which
JRE you choose (at least: "Cacao" and "headless"). Of course they're in
different dirs and I'm not sure about which is the right way (or even
criteria) to choose one.

After having passed through that (with a dirty symlink to one of the two
libjvm.so), the shipped example fails with an exception while
initializing the JVM:

  LOG: [0x00002b9a57f73c80] exception thrown while VM is initializing: 
  LOG: [0x00002b9a57f73c80] NULL: java.lang.Object
  LOG: [0x00002b9a57f73c80] Aborting...

(this is with Cacao, with headless an exception its OCaml, but
apparently it is devoid of any inspectable content.)

Has any one here a success story to share?
Is there a planned future release of CamlJava?

Many thanks in advance,
Cheers.

[1] http://pauillac.inria.fr/~xleroy/software.html#camljava

-- 
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] CamlJava - patch to *build* w/ recent JDK
  2009-11-23 15:55 CamlJava w/ recent OCaml (3.11.1) and Sun's JVM (OpenJDK) Stefano Zacchiroli
@ 2009-11-24 14:00 ` Stefano Zacchiroli
  2009-12-01 10:52 ` CamlJava w/ recent JVMs - solved (patches needed and included) Stefano Zacchiroli
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Zacchiroli @ 2009-11-24 14:00 UTC (permalink / raw)
  To: OCaml Mailing List; +Cc: Xavier Leroy

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]

On Mon, Nov 23, 2009 at 04:55:37PM +0100, Stefano Zacchiroli wrote:
> Has anyone successfully built/used CamlJava [1] with recent OCaml and
> the open sourced Sun's JVM (OpenJDK)?  I've tried for a while, but I'm
> stuck at the basics, i.e. making the example shipped with CamlJava work.
> 
> First of all there is some needed gymnastic to build: apparently there
> is no longer _a_ legacy libjvm.so, but several one depending on which
> JRE you choose (at least: "Cacao" and "headless"). Of course they're in
> different dirs and I'm not sure about which is the right way (or even
> criteria) to choose one.

About this, here is a patch for the build system which makes CamlJava
build against both last Sun's JDK 6 (closed source) and last Open JDK.
It mainly account for libjvm.so having been moved around and some
upstream lib/ directory reorganization.

> After having passed through that (with a dirty symlink to one of the two
> libjvm.so), the shipped example fails with an exception while
> initializing the JVM:

This, unfortunately, is still standing :-(

Cheers.


PS I hope I'm not bothering with list + author's Cc, AFAIK there is no
   BTS for CamlJava, so this is my best attempt for both being sure the
   author gets the patch and that the patch is public for consumptions
   by others

-- 
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime

[-- Attachment #2: camljava-java6.patch --]
[-- Type: text/x-diff, Size: 2578 bytes --]

diff -Naur camljava-0.3.orig/lib/Makefile camljava-0.3/lib/Makefile
--- camljava-0.3.orig/lib/Makefile	2009-11-24 14:43:18.555035491 +0100
+++ camljava-0.3/lib/Makefile	2009-11-24 14:42:07.943485242 +0100
@@ -46,7 +46,7 @@
 	rm -f fr/inria/caml/camljava/*.class
 
 clean::
-	rm -f *.cm? *.[oa]
+	rm -f *.cm? *.[oa] *.cmxa
 
 .SUFFIXES: .ml .mli .cmo .cmi .cmx
 
diff -Naur camljava-0.3.orig/Makefile.config camljava-0.3/Makefile.config
--- camljava-0.3.orig/Makefile.config	2004-07-08 16:02:53.000000000 +0200
+++ camljava-0.3/Makefile.config	2009-11-24 14:52:27.474829525 +0100
@@ -17,7 +17,7 @@
 ## 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/local/java_1.4.2
+JDKHOME=/usr/lib/jvm/java-6-sun
 
 # Where to find the JNI include files (for compiling the OCaml-JNI C stubs)
 JNIINCLUDES=-I$(JDKHOME)/include -I$(JDKHOME)/include/linux
@@ -25,11 +25,18 @@
 # The library to link with to get the JNI
 JNILIBS=-ljava
 
+# 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
+
 # Additional link-time options to pass to $(CC) when linking with $(JNILIBS)
-JNILIBOPTS=-L$(JDKHOME)/jre/lib/i386/ \
-        -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
diff -Naur camljava-0.3.orig/test/jnitest.ml camljava-0.3/test/jnitest.ml
--- camljava-0.3.orig/test/jnitest.ml	2001-06-05 16:01:23.000000000 +0200
+++ camljava-0.3/test/jnitest.ml	2009-11-24 14:37:41.602405336 +0100
@@ -68,4 +68,6 @@
   print_newline()
 
 let _ =
-  test()
+  try
+    test()
+  with exn -> prerr_endline (Printexc.to_string exn)
diff -Naur camljava-0.3.orig/test/Makefile camljava-0.3/test/Makefile
--- camljava-0.3.orig/test/Makefile	2001-06-05 16:01:15.000000000 +0200
+++ camljava-0.3/test/Makefile	2009-11-24 14:44:01.335369289 +0100
@@ -18,3 +18,4 @@
 
 clean::
 	rm -f *.cm?
+	rm -f *.class

^ permalink raw reply	[flat|nested] 3+ messages in thread

* CamlJava w/ recent JVMs - solved (patches needed and included)
  2009-11-23 15:55 CamlJava w/ recent OCaml (3.11.1) and Sun's JVM (OpenJDK) Stefano Zacchiroli
  2009-11-24 14:00 ` [Caml-list] CamlJava - patch to *build* w/ recent JDK Stefano Zacchiroli
@ 2009-12-01 10:52 ` Stefano Zacchiroli
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Zacchiroli @ 2009-12-01 10:52 UTC (permalink / raw)
  To: OCaml Mailing List; +Cc: Xavier Leroy, Grégoire Henry

On Mon, Nov 23, 2009 at 04:55:37PM +0100, Stefano Zacchiroli wrote:
> Has anyone successfully built/used CamlJava [1] with recent OCaml and
> the open sourced Sun's JVM (OpenJDK)?

With the tremendous help of Grégoire Henry, we've come up to a fixed
version of CamlJava that:

- works well with recent JVMs (both Sun's 1.6 and OpenJDK)
  * fixes are both for building and for avoiding segfaults due to a
    distinction among local and global references introduced by JNI 1.6
- is a bit more debugger friendly
- has _conditional_ automatic mapping of Java strings to OCaml strings
  (needed by O'Jacare [1])
- is a bit more careful/strict in case of multithreading: you must
  ensure all Java-OCaml callbacks are called from the very same thread
  (need spotted by O'Jacare a while ago)
- fixes various minor issues that help packages

All patches are available at [2] and contain appropriate
descriptions.

The patches are integrated in the Debian package of CamlJava that I've
just uploaded to the archive. While the package gets processed for
copyright review, it is also available at:

  deb http://people.debian.org/~zack/debian zack-unstable/
  deb-src http://people.debian.org/~zack/debian zack-unstable/

Xavier: can you please consider integrating the above patches in a new
release of CamlJava?

AFAIK, a new release of O'Jacare based on the above work is being worked
on by Grégoire.

Cheers.

[1] http://www.pps.jussieu.fr/~henry/ojacare/index.en.html
[2] http://git.debian.org/?p=pkg-ocaml-maint/packages/camljava.git;a=tree;f=debian/patches

-- 
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-01 10:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-23 15:55 CamlJava w/ recent OCaml (3.11.1) and Sun's JVM (OpenJDK) Stefano Zacchiroli
2009-11-24 14:00 ` [Caml-list] CamlJava - patch to *build* w/ recent JDK Stefano Zacchiroli
2009-12-01 10:52 ` CamlJava w/ recent JVMs - solved (patches needed and included) Stefano Zacchiroli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).