- Back from FOSDEM 2016
- Haiku monthly activity report - 12/2015
- Capitole^W Bazar du Libre 2015
- A short report of BeGeistert 029
- Haiku monthly activity report - 10/2015
- Haiku monthly activity report - 09/2015
- Haiku monthly activity report - 08/2015
- 'Packaging Infrastructure' Final Weekly Report
- Haiku monthly activity report - 07/2015
- 'Packaging Infrastructure' Contract Weekly Report #7
Haiku on Java
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't require too much tedious work. Given these points, I decided to go with SWIG, and I have put the results (so far) on Github.
Currently, I have two tests, one that runs a custom handler on the BApplication thread (also works running it on an extra BLooper) and listens for messages. The other test makes a very simple GUI using the Haiku API. Check out the result of this test in the image on the right. That's a BWindow with a BButton and a BGroupLayout and a BStringView, all created with Java code!!!
There are still some issues, but I'm really excited about the progress that I've made already, and I'm very impressed with SWIG! As I said in the README on Github, having Java bindings also opens up the door for any JVM language to use the Haiku API, for instance Jython, JRuby, and Scala to name a few. If you're interested in contributing, head over to github and fork the project. If you just want to try it out, it's really easy to do that, there are instructions on github in the README.