Avik’s Ruminations

Musings on technology and life by Avik Sengupta

Compiled with GCJ

without comments

GCJ has always been an interesting project to watch, but only recently have I felt emboldened enough to try out some (precompiled) apps, thanks to the “folks”:http://people.redhat.com/gbenson/naoko/ at RedHat. I used the precompiled versions of tomcat and ant on some of our smaller projects, on a RH9(RedHat 9) desktop. Herewith, some experiences.


In spite of knowing better, I harboured delusions about native vs bytecode compilation. So the first thing I did was to time gcj-ant against java-ant on a small webapp as well as a small swing project and found no measurable difference between the two. gcj-ant however managed to compile both projects correctly, but I suppose that is not saying much. Though I must admit I have been using gcj compiled *Eclipse* on a RHEL(RedHat Enterprise Linux) box, and that seems to start up much faster. (But its Eclipse 2, so again, not much use!)
Tomcat was more interesting. I was pleseantly surprised to find everything runs well, at a resonable speed. Startup is however much slower than using Java.
The first thing to watch out for is that the rpm is packaged in accordance with “FHS”:http://www.pathname.com/fhs/ (or is it “LSB”:http://www.linuxbase.org/ these days). So it has startup files in _/etc/init.d/_ and server.xml resides in _/etc/tomcat/_, and logs go to _/var/logs/tomcat/_. The process runs as user _tomcat_ and all files are owned by root or tomcat. All very nice and secure, but a pain to develop on. You end up spending a lot of time typing chmod -r 777 in frustration, to get you application to write its log, to read the logs, or when you want to clean your jsp working directory.
Its fun to see stack traces starting from __libc_start_main and going through org.apache.catalina.core.StandardContext.start() (/usr/lib/lib-org-apache-catalina-4.1.27.so) . But there hides the deal breaker. The GCJ runtime shows _Unknown Source_ in the stack trace, while the Sun JVM shows me the line number in the source code for the exact same bytecode. And that is why its a no-go for a developer.
So right now, I see no particular reason to use gcj in anger. The speed is similar, stability is similar, and trouble shooting ability is significantly lower. Since most of our work is server side, this solves no problem that we have. There may be a more compelling argument for desktop apps, where “this”:http://thisiscool.com/gcc_mingw.htm seems very cool.
Another bottleneck is that its still too difficult to compile large applications myself. The RedHat compilations are done using some bleeding edge code from GCC HEAD. Most online HOWTO’s seem to require five unofficial patches to GCC to do stuff. Scary stuff!
Next stop: “IKVM”:http://weblog.ikvm.net/ . I think IKVM has a more compelling use case — java/.net interop. “This”:http://primates.ximian.com/~miguel//texts/gtkjava.html may be how things will come to pass, if mono catches on.

Written by

April 13th, 2004 at 10:30 pm

Posted in Technology