Haiku on Java

Blog post by yourpalal on Thu, 2012-03-01 22:36

As part of my work at the University of Auckland (which is drawing to a close soon) I have been looking at Java on Haiku. There is already some support for Java on Haiku. By running installoptionalpackage DevelopmentJava you can get the JamVM java virtual machine, GNU Classpath (including gjar, gjavah and maybe some other utilities), and ecj (the Eclipse Java compiler, which is written in Java). This is enough to run and compile basic Java apps. For instance, the popular Java buildtool Ant can run on Haiku.

Anyway, the reason I was investigating this is because the University of Auckland has a big Java library (a database, actually) that has been developed here, and Christof and Gerald (my supervisors) want to bring it to Haiku. To do this, we require the ability to write code that integrates with both Java libraries, and the Haiku API. I looked at various solutions:

  • gcj compiles Java to C++, but seemed like too big of a port
  • Java Native Interface (JNI) allows for writing C++ code that hosts a JavaVM and calls Java code, but is tedious to write.
  • SWIG can generate Java bindings to C++ libraries, even allowing Java classes to inherit from, and override virtual methods in, C++ classes.

SWIG is a mature solution that handles writing lots of JNI code, and the input files are pretty much just C++ headers, so it doesn'