Graphics on Jamaica/OpenJDK

Today I got the first graphics app running on Jamaica with OpenJDK:

SwingSet2 on Jamaica/OpenJDK

This doesn’t mean, that 50% of the stuff is working, this means that graphics (Java2D, TrueType fonts, Imaging, Swing, etc) are now fully supported on Jamaica with Linux. This may not seem impressive. After all, all the code is already there, right? Well, on Jamaica it’s not that easy. All the native code needs to be statically linked, which can be a real pain. On the way I found a handful of bugs, both in Jamaica and in OpenJDK, and implemented a bunch of new things in Jamaica (namely, FileChannel support and friends). Now I can happily go off to vacation on Lago Maggiore, yay! And when I come back, I can finally start implementing Java2D pipelines for our more exotic platforms like VxWorks, WindowsCE, Nano-X and OS-9. And finish off the CVS->Mercurial transition inside aicas.

How to (not) handle Java Exceptions

The last couple of days I was digging my way through OpenJDK’s AWT/Java2D/Font2D code and found a couple of antipatterns regarding Exception handling that really stole a lot of my time. I’d like to outline them and show sane alternatives that would have saved a lot of my time.

Ignoring exceptions

This is the most stupid, and frankly, the most widespread antipattern for exception handling, probably often a result of a combination of laziness and the need to handle checked exceptions:

try {
  // do something
} catch (SomeCheckedException ex) {
  // dunno what to do with this.
  // or even worse:
  // Should never happpen.

Really. Never ever do this. In the (possibly rare) case, that the application runs into this, it most likely ends up in an undefined state, and makes debugging a pain. (‘Hey, how does the VM get out of this method without returning? Duh! A swallowed exception!’ is usually my train of thoughts) At least, print out the exception:

catch (SomeException ex) {
  // maybe use logger to log this.

If you don’t know how to handle the exception, and don’t want to just swallow it, you could wrap it into an unchecked exception or even error (depending if you think this is an exceptional or error condition):

catch (SomeException ex) {
  SomeRuntimeException rte = new SomeRuntimeException();
  throw rte;

The replaced exception

I also see this pattern from time to time:

try {
  // do something.
} catch (SomeException ex) {
  throw new SomeOtherException(ex.getMessage());

This is only little more useful than swallowing the exception completely. Again, wrapping the exception properly is a much more helpful solution, as it gives the poor developer soul at least a stacktrace to work with:

catch (SomeException ex) {
  SomeOtherException ex2 = new SomeOtherException(ex.getMessage());
  throw ex2;

There are certainly more such antipatters, these are only two of them that stole a lot of my time. If you know more, please comment and add them below.

Trends Audio TA-10

Around christmas last year, I bought a Super T-Amp and a pair of Axiom M3 speakers. What can I say, I think I’m addicted by that T-Amp technology now :-). Some weeks ago I ordered an upgraded TA-10 amp from It takes some time to burn in before the amp comes to full bloom, and now it is really ‘ripe’. I’m really excited about this great sound that this little amp gets out of the speakers. The Super T is already great, and this amp is similar, only better in everything. Wider soundstage, more detailed sound, better dynamics. It’s just as if the musicians are in the room. Which is strange for orchestral music 😉 It has the same limitations as the Super T though: needs efficient speakers (mine have around 90db/w/m and it is just enough), no remote control, only one input, etc. But this is exactly right for me, I tend to follow the KISS priniciple here too. I also recently bought a used Sony DVP NS900 CD/SACD/DVD player for 150€, a reference player back when it was released. Together this makes a hifi setup for 600-700€ that sounds like something that is around 5x – 10x the price.

There are two downsides you have to be aware of if you plan on such a setup: First, it reveals many limitations of not-carefully-produced CDs (or every media for that matter). For example, I already spotted a couple of clipped passages on Johnny Cash’s ‘American IV’, and Norah Jones’ ‘Feels Like Home’ CDs, which are otherwise great sounding albums. Too bad that pop/rock CDs are often not well produced, with added compression etc, only to get more bang effect on cheap hifis.

The other ‘downside’ I experienced is, that this new setup changed my musical taste quite significantly. For example, I could never stand classical music. Now I know why: it ain’t no fun listening classical music on a bad hifi. Everything gets muddied up and distorted. Now I see that classical music can be much more interesting and rewarding than rock music (my god, if you told me that I would write something like this some years ago, I would have hit you over with something 😉 ) Similar with female voices. I seldomly bought female singer’s CDs, and I was never really excited about them. Now I listen to Norah Jones, Fiona Apple, Cat Power, etc more than anything else, and they sound soooo beautiful :-). I don’t want to say that changing or adding to your musical taste is a bad thing, or a disadvantage, but it is something you should be aware of before buying some good audio gear.

That said, the most important thing is to keep listening to music, and not technology. The net is full of audiophile babble and chatter, and it seems to me that many so called audiophiles see audio tech as a kind of status symbol. Recently I saw speaker cables for 4000€ in a hifi shop. WTF?? The T amps are pretty good at bringing down audio quality back to earth.

Caciocavallo progress

… goes in small but significant steps. Mouse dragging works now, as well as gradients (dunno, this seems to be gratis with the rendering pipeline, I haven’t implemented one bit for gradients). I can run real Swing apps already, and the things that work show awesome performance. I really think Escher’s performance is a killer, because it avoids JNI calls almost completely, and doesn’t need the buffer pipeline for that (like the OpenGL pipeline). It simply talks efficiently with the X server directly. Obviously, one missing piece is transparent images, I will add that next. Code is still on my server, as we still have no OpenJDK project yet.


AWT peer cleanup and docs

The last couple of days I spent going through the AWT peer interfaces and cleaning them up (get rid of all the duplicate and deprecated stuff there), and have now started to document the stuff. The first results can be found here. For now I only have ButtonPeer to ComponentPeer, but I will add the missing stuff during the next couple of days, and I will also add all other classes that are necessary and/or helpful (like Toolkit, GraphicsEnvironment, and some internal classes).

I’m also very excited about Mario‘s work with JOGL and Escher. This is so amazing to see (start) working.

Neil Young

This guy is always good for a surprise. In the past he has made records in a very wide variety of styles (and still be true to himself). Country, folk, rock, blues, punk, soul, grunge, electro, you name it – and he surely does something completely different. He’s always been very conservative with technology (except some funny experiments in the 80s), insisting on analogue recordings and media whenever possible, etc. Why am I telling you this, and do so on an otherwise Java-centric blog? Well, Neil Young joins Rich Sands Green for a keynote at JavaOne. The article claims that they are going to announce an interesting media project. This sounds really weird. This old analogue fanatic doing some digital multimedia stuff? With Java? OTOH, I really think he must be seriously interested in this, he has never been the guy that you can pay into talking about something which is only interesting for any company. So, this is going to be interesing. I really hope somebody makes a video of it. I wonder what that project is all about? A free replacement for javax.sound? I doubt that Neil Young would have any interest in this. Makes me wonder if all this has anything to do with Mario Torre playing Neil Young at last FOSDEM, while presenting his javax.sound implementation? 😀

On a related note, I will hopefully attend a Neil Young concert this summer (July, 9th) in Oberhausen. Would be fun to meet people there.

To celebrate all this news, I have a Schmankerl for all Neil Young fans and everybody else. I hope the RIAA won’t kill me for this. Here I have for you Sample And Hold. This is a very special and song. (And very unconventional for him. Back then, Geffen Music sued Neil Young over 3 million $$$ for unrepresentative music.) While it seems to hide under a wall of digital sound, it is still one of the most emotional and touching songs. It is about his heavily disabled son, trying to learn stuff on some machines. This version is the LP version, on the CD they released a completely different mix (but I like the LP version a lot more). After all this news, I wouldn’t be surprised if Neil Young released a techno or industrial album this year :-D.

Keep on Rocking In the Free World!! Yay!