Building Anathema on a Mac

Flagg said:
Hooray for closed source proprietary software!
Of which Java is really neither. IBM, for example, makes its own Java virtual machines. Java certainly isn't open source, but neither is it entirely closed.
 
After Sun's recent move to open source Java, aren't there any viable alternatives to Apple's 'efforts' at providing Mac users with a JRE?
 
Not that I've seen. Most Mac devs would rather use Cocoa anyway. If anyone would, it'd probably be IBM.
 
The current build of Anathema dies a horrible death at startup running under Snow Leopard. Looks like the splash screen code is dying (one more reason splash screens of every application should be taken out and beaten with reeds):

Code:
Exception details.

Class: java.lang.ExceptionInInitializerError
Message: null

Stack trace:

net.sf.anathema.Anathema.startApplication(Anathema.java:24)
org.java.plugin.boot.Boot.boot(Boot.java:346)
org.java.plugin.boot.Boot.main(Boot.java:243)
net.sf.anathema.AnathemaBootLoader.main(AnathemaBootLoader.java:11)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
apple.launcher.LaunchRunner.run(LaunchRunner.java:115)
apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)

Caused by java.lang.NullPointerException

net.sf.anathema.AnathemaSplashscreen.<init>(AnathemaSplashscreen.java:34)
net.sf.anathema.ProxySplashscreen.<init>(ProxySplashscreen.java:13)
net.sf.anathema.ProxySplashscreen.<clinit>(ProxySplashscreen.java:5)
net.sf.anathema.Anathema.startApplication(Anathema.java:24)
org.java.plugin.boot.Boot.boot(Boot.java:346)
org.java.plugin.boot.Boot.main(Boot.java:243)
net.sf.anathema.AnathemaBootLoader.main(AnathemaBootLoader.java:11)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
apple.launcher.LaunchRunner.run(LaunchRunner.java:115)
apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)

-----------------------------------------------
System properties:

apple.awt.graphics.UseOpenGL=false
apple.awt.graphics.UseQuartz=false
apple.laf.useScreenMenuBar=true
awt.nativeDoubleBuffering=true
awt.toolkit=apple.awt.CToolkit
defaultrepository=%USER_HOME%/Library/Application Support/Anathema
file.encoding=MacRoman
file.encoding.pkg=sun.io
file.separator=/
gopherProxySet=false
java.awt.graphicsenv=apple.awt.CGraphicsEnvironment
java.awt.printerjob=apple.awt.CPrinterJob
java.class.path=/Applications/Games/Anathema.app/Contents/Resources/Java/anathema.jar
java.class.version=50.0
java.endorsed.dirs=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/endorsed
java.ext.dirs=/Users/lward/Library/Java/Extensions:/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext
java.home=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
java.io.tmpdir=/var/folders/LC/LCPBjjFYEzqYTVyw3K9ydE+++TI/-Tmp-/
java.library.path=/Applications/Games/Anathema.app/Contents/Resources/Java:/System/Library/PrivateFrameworks/JavaApplicationLauncher.framework/Resources:.:/Users/lward/Library/Java/Extensions:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
java.runtime.name=Java(TM) SE Runtime Environment
java.runtime.version=1.6.0_15-b03-219
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.6
java.vendor=Apple Inc.
java.vendor.url=http://www.apple.com/
java.vendor.url.bug=http://bugreport.apple.com/
java.version=1.6.0_15
java.vm.info=mixed mode
java.vm.name=Java HotSpot(TM) Client VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Apple Inc.
java.vm.version=14.1-b02-90
jpf.boot.mode=shell
line.separator=

mrj.version=1060.1.6.0_15-219
org.java.plugin.jpf-version=1.5.1
os.arch=i386
os.name=Mac OS X
os.version=10.6
path.separator=:
sun.arch.data.model=32
sun.awt.exception.handler=apple.awt.CToolkit$EventQueueExceptionHandler
sun.boot.library.path=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Libraries
sun.cpu.endian=little
sun.cpu.isalist=
sun.io.unicode.encoding=UnicodeLittle
sun.jnu.encoding=MacRoman
sun.management.compiler=HotSpot Client Compiler
sun.os.patch.level=unknown
user.country=US
user.dir=/Applications/Games/Anathema.app/Contents/Resources/Java

-----------------------------------------------
Runtime info:

Memory TOTAL / FREE / MAX: 65011712 / 55552256 / 65011712
Available processors: 4
System class loader: sun.misc.Launcher$AppClassLoader@1a7bf11
Thread context class loader: sun.misc.Launcher$AppClassLoader@1a7bf11
Security manager: null

If I get a chance, I'll see if I can figure it out.


This page says:

After Snow Leopard installation, only Java SE 6 remains and is used for all Java applications and applets; previous Java versions (which were present in Leopard and Tiger) are gone. This may cause issues with Java apps/applets that don't work correctly with Java SE 6: these will need to be updated to work with Snow Leopard.
This means, it sounds like, that it may be difficult to do build-once-run-anywhere with Anathema on the Mac. My recollection is that Tiger, for example, will never have Java 1.6 on it, while Snow Leopard appears to have nothing else. Joy.
 
I hate to play thread necromancer here, but I felt it necessary as I debugged the above issue reported by wordman (i.e. the java.lang.ExceptionInInitializerError and java.lang.NullPointerException bug in net.sf.anathema.Anathema.startApplication and net.sf.anathema.AnathemaSplashscreen.<init>), and came across this with a Google search (which is why I reiterate the key bits of the error, so this page gets picked up as well), so I suspect this will help others who might end up finding this post.


The issue boils down to a hard-coded Java version check in AnathemaSplashscreen.java (as compiled into core.jar), which only tests against Java 1.5, and not Java 1.6 or (the beta) Java 1.7. I was able to get it to work by default on Leopard AND Snow Leopard by adjusting isSplashScreenSupported() to:

Code:
 private boolean isSplashScreenSupported() {
   String version = System.getProperty("java.version");
   return !version.startsWith("1.5") && !version.startsWith("1.6") && !version.startsWith("1.7"); //$NON-NLS-1$ //$NON-NLS-2$
 }

I'll be editing this post later with a proper patch file, but if you unzip the core.jar file (since jar files are zip files) and substitute this AnathemaSplashscreen.class file for the existing class file (in net/sf/anathema/) before rezipping with the same directory structure (be careful to make sure the directory hierarchy matches the original file), it should work on both Leopard's 1.5 AND Snow Leopard's 1.6 (although I did not test on Tiger).
 
Thanks for the info. If I recall, the whole point of this check is to see if some API is supported, and there are probably much better ways of testing that than looking at the Java version. I'll look into it if I can muster the energy.
 
I've located all the points in the code where version 1.5 is explicitly checked for and have now created patches for the trunk, as well as the Outcaste, and Release_1.1 branches in a tarball here. Of note are the fact that ProxySplashscreen.class, and, for the branches, AnathemaBootLoader.class and AnathemaDevelopmentBootLoader.class, also need replacement.


(Note that the class files I have linked are compiled from trunk, and not the branches.
 
New version is up. I wound up using a different fix:

Code:
public static boolean isSplashScreenSupported() 
{
String osName = (String)AccessController.doPrivileged(new GetPropertyAction("os.name"));
return !osName.contains("Mac OS X");
}

Should be a bit more bullet proof. One odd thing is that the splashscreen works fine in the debugger. Might be some order of initialization thing.
 
wordman said:
Should be a bit more bullet proof. One odd thing is that the splashscreen works fine in the debugger. Might be some order of initialization thing.
It works. Thanks a million!
 

Users who are viewing this thread

Back
Top