MacOS – Install 32bit Java 7 OpenJDK

32-bitjavamacos

Motivation

I have a proprietary java application which used to work under Snow Leopard but fails under Lion with the following backtrace:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid display mode
    at apple.awt.CGraphicsDevice.setDisplayMode(CGraphicsDevice.java:472)
    at apple.awt.CGraphicsDevice.setFullScreenWindowSynchronized(CGraphicsDevice.java:363)
    at apple.awt.CGraphicsDevice.access$000(CGraphicsDevice.java:25)
    at apple.awt.CGraphicsDevice$1SetFullScreenAction.run(CGraphicsDevice.java:326)
    at apple.awt.CGraphicsDevice.setFullScreenWindow(CGraphicsDevice.java:331)

The call to setFullScreenWindow only passes null, i.e. it attempts to restore from full-screen to windowed mode. The error only occurs when a beamer is connected and thus the screen resolution is adjusted to 1024×768. Looks like a bug in the Java VM to me.

Looking at the code, it seems to me that OpenJDK 7 might have addressed this issue. So I want to give that a try.

Failed approach

However, even after downloading Java SE 7u7 from Oracle, I can't use it to execute the application, as the application uses some 32bit native code, which this JVM doesn't support:

> /Library/Java/JavaVirtualMachines/jdk1.7.0_07.j/Contents/Home/bin/java -d32 -version
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.

Core question

So my core question is this: is it possible to install a 32 bit build of a recent version of OpenJDK 7 on Mac OS X Lion? Preferrably as a precompiled package, but if that isn't available, then a well-written instruction how to compile that myself would serve my purpose as well.

Best Answer

It seems I found a source of precompiled OpenJDK:
http://code.google.com/p/openjdk-osx-build/
The OpenJDK 7 builds there are universal, and do indeed run in 32bit mode. The latest version is 7u6, which is not quite as recent as the 7u7 available from Oracle, but should be recent enough for my requirements.

Alas, my original problem persists, so I might have to compile my JVM myself after all. I found there is a jdk7u-osx repository in the OpenJDK mercurial repositories, and its README-builds file provides reasonable instructions on how to build stuff. The part about source drops appears particularly important. I still have some troubles, but those seem to be bugs in the build process or similar, so I'll take them up with the macosx-port-dev mailing list.