yourpalal's blog

Back from Auckland

Blog post by yourpalal on Thu, 2012-05-03 16:51

With one big push the work I did on ALM (Auckland Layout Model) while I was at the University of Auckland is now in the main Haiku repo. In short, I’ve brought the BALMLayout up to standard with the other layouts in Haiku, and added some new features as well.

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'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.

Tales From the Land of Auck and Zea

Blog post by yourpalal on Thu, 2012-02-16 21:42

As was announced a little while ago, I recently got the opportunity to travel to Auckland, New Zealand to do some Computer Science research at the University of Auckland (UoA) with Christof Lutteroth and Gerald Weber (two professors here). Actually, it's not so much 'recently' as it is 'currently', since I'm still here! Christof has been interested in Haiku for a while, and has already done some research using Haiku. Stack and Tile, for instance, started as a research project here, as did the BALMLayout layout class. Furthermore, I'm not the only Haiku-er here, as Clemens Zeidler is currently working on his PhD in CS under the supervision of Christof and Gerald.

My supervisors have been very flexible with what I can work on, and we decided the first thing I should do is work on the BALMLayout. BALMLayout (ALM = Auckland Layout Model) is based on the idea of a constraint-based layout, where the programmer doesn't explicitly position elements, but rather describes how they must be positioned relative to each other or the layout area, and ALM figures it out. Since the code for BALMLayout was written before I started working on Haiku's layout API, BALMLayout had fallen behind a bit. So one thing I worked on was getting it up to date with the API. There were also a few things that BALMLayout was doing a bit differently from the other layout classes, which I've now normalized. I've also implemented a layout builder class for ALM, like the ones that exist for other layouts. The end goal is to have BALMLayout promoted to be a first-class layout, included in, like the Grid, Group, and Card layouts. Although I've already written a bunch of code, I haven't yet pushed it to the main Haiku repo, but that's something I hope to do soon.

The next project I'm working on is pretty interesting in a few ways, as it includes running and compiling Java code on Haiku (using JamVM, GNUClasspath, and Eclipse's ecj compiler), and calling Java code from C++ as well (using JNI). Although this work is more experimental, it should pave the way for using PDStore, a triplestore database developed at the UoA on Haiku, basically making it available to C++ programs as a library.

Now that you guys know what I'm up to, I want to thank everyone who helped make this trip possible: Haiku folks, UoA folks, my family and also Google (especially Carol Smith at the Open Source Programs Office), who provided me with a grant to keep things running smoothly.