The goal of the project is to provide seamless integration of OCaml and Java: run OCaml code on a JVM, and manipulate Java entities from OCaml.
This site is replacing the previous one, hosted on
x9c.fr. The code repository is published on
github.com, where issues can be reported.
For quite a long time, the project was only available as a binary distribution. Now that the code is in better shape, its sources are available.
The compiler supports the whole OCaml language (version 4.01.0), and generates plain Java bytecode. Moreover, the runtime support library does not use native code. Produced jar files can thus be run on any 1.7+ JVM.
The default behavior of the compiler is to generate standalone applications, but the developer can use alternative compilation and link modes in order to produce applets (to be run inside a browser), or servlets (to be run inside a servlet container).
The compiler features a typer extension allowing to manipulate Java entities from OCaml code. Java class instances are thus given proper types in OCaml programs, enabling complete typing of instance creations, method calls, and field accesses.
The generated code usually runs faster than OCaml bytecode but slower than native code. Memory consumption and startup time are also higher, but leveraging the multiple cores of a machine can help reaching the performance level of native code.
The runtime library does not rely on a global lock, and takes advantage of the Java GC to enable shared-memory concurrent programming. Furthermore, Java basic building blocks such as fork/join are presented through an OCaml interface.
The compiler as well as associated tools and libraries can be fully installed through OPAM. A patched version of findlib is also available, allowing to easily distribute and use code to be compiled with the OCaml-Java compiler.