Go...
Welcome
Feeds
Java SE 6 on Mac (Success)
Posted by ccondit on 11/16/07 @ 4:29 PM :: Updated by ccondit on 11/20/07 @ 8:41 AM
Tags :: ::

There appears to be some hope for Java developers on the Mac platform... it is now possible, thanks to Landon Fuller , to build a patched version of FreeBSD's Java 1.6.0_03 on Mac OS Leopard.

I can confirm that this works, at least for non-GUI code. I successfully compiled and ran a 64-bit VM. 32-bit was more problematic; all attempts at building caused a JVM crash which I was not able to overcome. Update: I am now able to successfully build and run the 32-bit VM as well.

Java 1.6.0 running on Leopard

$ java -version
java version "1.6.0_03-p3"
Java(TM) SE Runtime Environment (build 1.6.0_03-p3-ccondit_16_nov_2007_13_44-b00)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-p3-ccondit_16_nov_2007_13_44-b00, mixed mode)
$ uname -a
Darwin localhost 9.1.0 Darwin Kernel Version 9.1.0: Wed Oct 31 17:46:22 PDT 2007;
root:xnu-1228.0.2~1/RELEASE_I386 i386

Benchmarks

I ran DaCapo 2006-10-MR2 on several JVMs on my development system, mainly to expose any serious bugs but also to find out if the new runtime had any major performance issues. The results were encouraging:

Java 1.5.0_13 (Apple provided, 32-bit)

  • antlr : 3251 msec
  • bloat : 8276 msec
  • chart : 7984 msec
  • eclipse : 33968 msec
  • fop : 2825 msec
  • hsqldb : 3981 msec
  • jython : 8636 msec
  • lusearch : 7104 msec
  • luindex : 8416 msec
  • pmd : 7477 msec
  • xalan : 5070 msec

Java 1.5.0_13 (Apple provided, 64-bit)

  • antlr : 4256 msec
  • bloat : 5895 msec
  • chart : 6181 msec
  • eclipse : 30654 msec
  • fop : 2917 msec
  • hsqldb : 4603 msec
  • jython : 9664 msec
  • lusearch : 4301 msec
  • luindex : 6046 msec
  • pmd : 6420 msec
  • xalan : 7232 msec

Java 1.6.0_03 (Custom FreeBSD, 64-bit)

  • antlr : 2379 msec
  • bloat : 5362 msec
  • chart : 5256 msec
  • eclipse : 26955 msec
  • fop : 2382 msec
  • hsqldb : 4078 msec
  • jython : 6953 msec
  • lusearch : 3831 msec
  • luindex : 5607 msec
  • pmd : 5566 msec
  • xalan : 4530 msec

As you can see, the FreeBSD 1.6.0 JVM performs very well against Apple's provided 1.5.0 JVM, so performance is not a great concern. Even more importantly, all benchmarks completed without errors. There are still some known AMD64 bugs, which Fuller documents on his site. To work around a few of these, it may be necessary to run HotSpot in interpreted mode by adding -Xint to the java command line. This tended to slow down execution between 2 and 10 times depending on the code being run. I was able to duplicate this bug during the build of the JDK, but fortunately, not on my own code so far.

The final test was to bootstrap the randomCoder.com website and execute it in a Tomcat 6 instance on the new JDK. The first try was disappointing, as several unit tests failed. However, these were all due to the new JDK having limited-strength JCE policy files installed. After replacing these with the Sun unlimited strength policy files, all unit tests passed, and Tomcat 6 started up without a hitch.

I'm hoping to be able to configure Eclipse to target the new JDK for my projects, and the new JVM to run my maven builds. This should let me take advantage of Java 6 features in my server deployments until Apple gets around to releasing something better. This also gets us one step closer to getting OpenJDK to build -- the last time I tried that, it needed a previously installed JDK 6 to bootstrap with, which I now have.

Caveats

  • Forget about GUI apps for now, at least if you want a native look and feel, as the FreeBSD JDK uses X11 for Swing and AWT.
  • Audio support is unavailable.
  • Stack-alignment issues make JNI problematic.
  • Remember, this is not beta or even alpha-level code. It will may break on you when you least expect, so don't even think about running any production code on this.

Again, a huge shout out to Landon Fuller, who made all of this possible. Any other Java hackers out there, feel free to dive in and help fix some of the remaining issues. Java on Mac still has a long way to go, but we're one step closer today.

Update (Nov 20, 2007): It looks like Fuller has released this code as a developer preview now, and resolved most of the outstanding build issues. Links and results have been updated.

Comment on this article

Comments are closed for this post.