Skip to main content

How to integrate OpenJDK 7 EA with Mac OS X platform

No replies
worldwizard
Offline
Joined: 2010-03-22

Java code:

// Platform.java
package com.puttysoftware.platform;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.swing.JFrame;
import javax.swing.UIManager;

import apple.dts.samplecode.osxadapter.OSXAdapter;

public class Platform {

// Constructor
private Platform() {
// Do nothing
}

// Methods
public static void hookLAF(final String programName) {
if (System.getProperty("os.name").startsWith("Mac OS X")) {
// Mac OS X-specific stuff
System.setProperty(
"com.apple.mrj.application.apple.menu.about.name",
programName);
System.setProperty("apple.laf.useScreenMenuBar", "true");
} else if (System.getProperty("os.name").startsWith("Windows")) {
// Windows-specific stuff
try {
// Tell the UIManager to use the platform native look and
// feel
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
// Hint to the UI that the L&F is decorated
JFrame.setDefaultLookAndFeelDecorated(true);
} catch (final Exception e) {
// Do nothing
}
} else {
// All other platforms
try {
// Tell the UIManager to use the Nimbus look and feel
UIManager
.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
// Hint to the UI that the L&F is decorated
JFrame.setDefaultLookAndFeelDecorated(true);
} catch (final Exception e) {
e.printStackTrace();
}
}
}

public static void hookFileOpen(Object o, Method m, String s) {
if (System.getProperty("os.name").startsWith("Mac OS X")) {
OSXAdapter.setFileHandler(o, m);
} else {
try {
m.invoke(o, s);
} catch (IllegalArgumentException e) {
// Ignore
} catch (IllegalAccessException e) {
// Ignore
} catch (InvocationTargetException e) {
// Ignore
}
}
}

public static void hookQuit(Object o, Method m) {
if (System.getProperty("os.name").startsWith("Mac OS X")) {
OSXAdapter.setQuitHandler(o, m);
}
}

public static void hookPreferences(Object o, Method m) {
if (System.getProperty("os.name").startsWith("Mac OS X")) {
OSXAdapter.setPreferencesHandler(o, m);
}
}

public static void hookAbout(Object o, Method m) {
if (System.getProperty("os.name").startsWith("Mac OS X")) {
OSXAdapter.setAboutHandler(o, m);
}
}
}

// OSXAdapter.java
/*

File: OSXAdapter.java

Abstract: Hooks existing preferences/about/quit functionality from an
existing Java app into handlers for the Mac OS X application menu.
Uses a Proxy object to dynamically implement the
com.apple.eawt.ApplicationListener interface and register it with the
com.apple.eawt.Application object.  This allows the complete project
to be both built and run on any platform without any stubs or
placeholders. Useful for developers looking to implement Mac OS X
features while supporting multiple platforms with minimal impact.

Version: 2.0

Disclaimer: IMPORTANT:  This Apple software is supplied to you by
Apple Inc. ("Apple") in consideration of your agreement to the
following terms, and your use, installation, modification or
redistribution of this Apple software constitutes acceptance of these
terms.  If you do not agree with these terms, please do not use,
install, modify or redistribute this Apple software.

In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc.
may be used to endorse or promote products derived from the Apple
Software without specific prior written permission from Apple.  Except
as expressly stated in this notice, no other rights or licenses, express
or implied, are granted by Apple herein, including but not limited to
any patent rights that may be infringed by your derivative works or by
other works in which the Apple Software may be incorporated.

The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.

IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Copyright 2003-2007 Apple, Inc., All Rights Reserved

*/
package apple.dts.samplecode.osxadapter;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class OSXAdapter implements InvocationHandler {

protected Object targetObject;
protected Method targetMethod;
protected String proxySignature;
static Object macOSXApplication;

// Pass this method an Object and Method equipped to perform application
// shutdown logic
// The method passed should return a boolean stating whether or not the quit
// should occur
public static void setQuitHandler(Object target, Method quitHandler) {
OSXAdapter
.setHandler(new OSXAdapter("handleQuit", target, quitHandler));
}

// Pass this method an Object and Method equipped to display application
// info
// They will be called when the About menu item is selected from the
// application menu
public static void setAboutHandler(Object target, Method aboutHandler) {
boolean enableAboutMenu = (target != null && aboutHandler != null);
if (enableAboutMenu) {
OSXAdapter.setHandler(new OSXAdapter("handleAbout", target,
aboutHandler));
}
// If we're setting a handler, enable the About menu item by calling
// com.apple.eawt.Application reflectively
try {
Method enableAboutMethod = OSXAdapter.macOSXApplication.getClass()
.getDeclaredMethod("setEnabledAboutMenu",
new Class<?>[] { boolean.class });
enableAboutMethod.invoke(OSXAdapter.macOSXApplication,
new Object[] { Boolean.valueOf(enableAboutMenu) });
} catch (Exception ex) {
System.err.println("OSXAdapter could not access the About Menu");
ex.printStackTrace();
}
}

// Pass this method an Object and a Method equipped to display application
// options
// They will be called when the Preferences menu item is selected from the
// application menu
public static void setPreferencesHandler(Object target, Method prefsHandler) {
boolean enablePrefsMenu = (target != null && prefsHandler != null);
if (enablePrefsMenu) {
OSXAdapter.setHandler(new OSXAdapter("handlePreferences", target,
prefsHandler));
}
// If we're setting a handler, enable the Preferences menu item by
// calling
// com.apple.eawt.Application reflectively
try {
Method enablePrefsMethod = OSXAdapter.macOSXApplication.getClass()
.getDeclaredMethod("setEnabledPreferencesMenu",
new Class<?>[] { boolean.class });
enablePrefsMethod.invoke(OSXAdapter.macOSXApplication,
new Object[] { Boolean.valueOf(enablePrefsMenu) });
} catch (Exception ex) {
System.err.println("OSXAdapter could not access the About Menu");
ex.printStackTrace();
}
}

// Pass this method an Object and a Method equipped to handle document
// events from the Finder
// Documents are registered with the Finder via the CFBundleDocumentTypes
// dictionary in the
// application bundle's Info.plist
public static void setFileHandler(Object target, Method fileHandler) {
OSXAdapter.setHandler(new OSXAdapter("handleOpenFile", target,
fileHandler) {
// Override OSXAdapter.callTarget to send information on the
// file to be opened

@Override
public boolean callTarget(Object appleEvent) {
if (appleEvent != null) {
try {
Method getFilenameMethod = appleEvent.getClass()
.getDeclaredMethod("getFilename",
(Class<?>[]) null);
String filename = (String) getFilenameMethod.invoke(
appleEvent, (Object[]) null);
this.targetMethod.invoke(this.targetObject,
new Object[] { filename });
} catch (Exception ex) {
}
}
return true;
}
});
}

// setHandler creates a Proxy object from the passed OSXAdapter and adds it
// as an ApplicationListener
public static void setHandler(OSXAdapter adapter) {
try {
Class<?> applicationClass = Class
.forName("com.apple.eawt.Application");
if (OSXAdapter.macOSXApplication == null) {
OSXAdapter.macOSXApplication = applicationClass.getConstructor(
(Class<?>[]) null).newInstance((Object[]) null);
}
Class<?> applicationListenerClass = Class
.forName("com.apple.eawt.ApplicationListener");
Method addListenerMethod = applicationClass.getDeclaredMethod(
"addApplicationListener",
new Class<?>[] { applicationListenerClass });
// Create a proxy object around this handler that can be
// reflectively added as an Apple ApplicationListener
Object osxAdapterProxy = Proxy.newProxyInstance(
OSXAdapter.class.getClassLoader(),
new Class<?>[] { applicationListenerClass }, adapter);
addListenerMethod.invoke(OSXAdapter.macOSXApplication,
new Object[] { osxAdapterProxy });
} catch (ClassNotFoundException cnfe) {
System.err
.println("This version of Mac OS X does not support the Apple EAWT.  ApplicationEvent handling has been disabled ("
+ cnfe + ")");
} catch (Exception ex) { // Likely a NoSuchMethodException or an
// IllegalAccessException loading/invoking
// eawt.Application methods
System.err.println("Mac OS X Adapter could not talk to EAWT:");
ex.printStackTrace();
}
}

// Each OSXAdapter has the name of the EAWT method it intends to listen for
// (handleAbout, for example),
// the Object that will ultimately perform the task, and the Method to be
// called on that Object
protected OSXAdapter(String proxySig, Object target, Method handler) {
this.proxySignature = proxySig;
this.targetObject = target;
this.targetMethod = handler;
}

// Override this method to perform any operations on the event
// that comes with the various callbacks
// See setFileHandler above for an example
public boolean callTarget(Object appleEvent)
throws InvocationTargetException, IllegalAccessException {
Object result = this.targetMethod.invoke(this.targetObject);
if (result == null) {
return true;
}
return Boolean.valueOf(result.toString()).booleanValue();
}

// InvocationHandler implementation
// This is the entry point for our proxy object; it is called every time an
// ApplicationListener method is invoked
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
if (this.isCorrectMethod(method, args)) {
boolean handled = this.callTarget(args[0]);
OSXAdapter.setApplicationEventHandled(args[0], handled);
}
// All of the ApplicationListener methods are void; return null
// regardless of what happens
return null;
}

// Compare the method that was called to the intended method when the
// OSXAdapter instance was created
// (e.g. handleAbout, handleQuit, handleOpenFile, etc.)
protected boolean isCorrectMethod(Method method, Object[] args) {
return (this.targetMethod != null
&& this.proxySignature.equals(method.getName()) && args.length == 1);
}

// It is important to mark the ApplicationEvent as handled and cancel the
// default behavior
// This method checks for a boolean result from the proxy method and sets
// the event accordingly
protected static void setApplicationEventHandled(Object event,
boolean handled) {
if (event != null) {
try {
Method setHandledMethod = event.getClass().getDeclaredMethod(
"setHandled", new Class<?>[] { boolean.class });
// If the target method returns a boolean, use that as a hint
setHandledMethod.invoke(event,
new Object[] { Boolean.valueOf(handled) });
} catch (Exception ex) {
System.err
.println("OSXAdapter was unable to handle an ApplicationEvent: "
+ event);
ex.printStackTrace();
}
}
}
}

This works properly on Apple's Java SE 6 (and earlier) but fails horribly on OpenJDK 7 EA. Is there recommended alternative code I don't know about?

Here's the exception I'm getting: (my test application still runs after this happens)

2012-03-15 18:14:01.016 java[5543:707] *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
2012-03-15 18:14:01.156 java[5543:707] (
0   CoreFoundation                      0x00007fff8c053fc6 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff8710cd5e objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8bffada8 -[__NSArrayM insertObject:atIndex:] + 296
3   AppKit                              0x00007fff87beaca1 -[NSMenu insertItem:atIndex:] + 478
4   liblwawt.dylib                      0x00000001184a5d35 addMenuItem + 185
5   liblwawt.dylib                      0x00000001184a5a26 -[ApplicationDelegate _updatePreferencesMenu:enabled:] + 211
6   liblwawt.dylib                      0x00000001184a6002 __Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState_block_invoke_1 + 227
7   JavaNativeFoundation                0x0000000117a935fd +[JNFRunLoop _performCopiedBlock:] + 20
8   CoreFoundation                      0x00007fff8c07de0d +[NSObject performSelector:withObject:] + 61
9   Foundation                          0x00007fff845c9d94 __NSThreadPerformPerform + 214
10  CoreFoundation                      0x00007fff8bfc26e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
11  CoreFoundation                      0x00007fff8bfc1f4d __CFRunLoopDoSources0 + 253
12  CoreFoundation                      0x00007fff8bfe8d39 __CFRunLoopRun + 905
13  CoreFoundation                      0x00007fff8bfe8676 CFRunLoopRunSpecific + 230
14  HIToolbox                           0x00007fff829e531f RunCurrentEventLoopInMode + 277
15  HIToolbox                           0x00007fff829ec5c9 ReceiveNextEventCommon + 355
16  HIToolbox                           0x00007fff829ec456 BlockUntilNextEventMatchingListInMode + 62
17  AppKit                              0x00007fff87bd3f5d _DPSNextEvent + 659
18  AppKit                              0x00007fff87bd3861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
19  libosxapp.dylib                     0x000000011854482c -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 124
20  AppKit                              0x00007fff87bd019d -[NSApplication run] + 470
21  libosxapp.dylib                     0x000000011854474b +[NSApplicationAWT runAWTLoopWithApp:] + 156
22  liblwawt.dylib                      0x00000001184a3ece -[AWTStarter starter:] + 1616
23  CoreFoundation                      0x00007fff8c04375d -[NSObject performSelector:withObject:] + 61
24  Foundation                          0x00007fff845c9d94 __NSThreadPerformPerform + 214
25  CoreFoundation                      0x00007fff8bfc26e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26  CoreFoundation                      0x00007fff8bfc1f4d __CFRunLoopDoSources0 + 253
27  CoreFoundation                      0x00007fff8bfe8d39 __CFRunLoopRun + 905
28  CoreFoundation                      0x00007fff8bfe8676 CFRunLoopRunSpecific + 230
29  java                                0x000000010bd3a4bc CreateExecutionEnvironment + 871
30  java                                0x000000010bd34cac JLI_Launch + 1952
31  java                                0x000000010bd3a819 main + 101
32  java                                0x000000010bd34504 start + 52
33  ???                                 0x0000000000000005 0x0 + 5
)
2012-03-15 18:14:01.157 java[5543:707] *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
2012-03-15 18:14:01.160 java[5543:707] (
0   CoreFoundation                      0x00007fff8c053fc6 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff8710cd5e objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8bffada8 -[__NSArrayM insertObject:atIndex:] + 296
3   AppKit                              0x00007fff87beaca1 -[NSMenu insertItem:atIndex:] + 478
4   liblwawt.dylib                      0x00000001184a5d35 addMenuItem + 185
5   liblwawt.dylib                      0x00000001184a5a26 -[ApplicationDelegate _updatePreferencesMenu:enabled:] + 211
6   liblwawt.dylib                      0x00000001184a6002 __Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState_block_invoke_1 + 227
7   JavaNativeFoundation                0x0000000117a935fd +[JNFRunLoop _performCopiedBlock:] + 20
8   CoreFoundation                      0x00007fff8c07de0d +[NSObject performSelector:withObject:] + 61
9   Foundation                          0x00007fff845c9d94 __NSThreadPerformPerform + 214
10  CoreFoundation                      0x00007fff8bfc26e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
11  CoreFoundation                      0x00007fff8bfc1f4d __CFRunLoopDoSources0 + 253
12  CoreFoundation                      0x00007fff8bfe8d39 __CFRunLoopRun + 905
13  CoreFoundation                      0x00007fff8bfe8676 CFRunLoopRunSpecific + 230
14  HIToolbox                           0x00007fff829e531f RunCurrentEventLoopInMode + 277
15  HIToolbox                           0x00007fff829ec51b ReceiveNextEventCommon + 181
16  HIToolbox                           0x00007fff829ec456 BlockUntilNextEventMatchingListInMode + 62
17  AppKit                              0x00007fff87bd3f5d _DPSNextEvent + 659
18  AppKit                              0x00007fff87bd3861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
19  libosxapp.dylib                     0x000000011854482c -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 124
20  AppKit                              0x00007fff87bd019d -[NSApplication run] + 470
21  libosxapp.dylib                     0x000000011854474b +[NSApplicationAWT runAWTLoopWithApp:] + 156
22  liblwawt.dylib                      0x00000001184a3ece -[AWTStarter starter:] + 1616
23  CoreFoundation                      0x00007fff8c04375d -[NSObject performSelector:withObject:] + 61
24  Foundation                          0x00007fff845c9d94 __NSThreadPerformPerform + 214
25  CoreFoundation                      0x00007fff8bfc26e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26  CoreFoundation                      0x00007fff8bfc1f4d __CFRunLoopDoSources0 + 253
27  CoreFoundation                      0x00007fff8bfe8d39 __CFRunLoopRun + 905
28  CoreFoundation                      0x00007fff8bfe8676 CFRunLoopRunSpecific + 230
29  java                                0x000000010bd3a4bc CreateExecutionEnvironment + 871
30  java                                0x000000010bd34cac JLI_Launch + 1952
31  java                                0x000000010bd3a819 main + 101
32  java                                0x000000010bd34504 start + 52
33  ???                                 0x0000000000000005 0x0 + 5
)
2012-03-15 18:14:01.163 java[5543:707] *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
2012-03-15 18:14:01.165 java[5543:707] (
0   CoreFoundation                      0x00007fff8c053fc6 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff8710cd5e objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8bffada8 -[__NSArrayM insertObject:atIndex:] + 296
3   AppKit                              0x00007fff87beaca1 -[NSMenu insertItem:atIndex:] + 478
4   liblwawt.dylib                      0x00000001184a5d35 addMenuItem + 185
5   liblwawt.dylib                      0x00000001184a5a26 -[ApplicationDelegate _updatePreferencesMenu:enabled:] + 211
6   liblwawt.dylib                      0x00000001184a6002 __Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState_block_invoke_1 + 227
7   JavaNativeFoundation                0x0000000117a935fd +[JNFRunLoop _performCopiedBlock:] + 20
8   CoreFoundation                      0x00007fff8c07de0d +[NSObject performSelector:withObject:] + 61
9   Foundation                          0x00007fff845c9d94 __NSThreadPerformPerform + 214
10  CoreFoundation                      0x00007fff8bfc26e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
11  CoreFoundation                      0x00007fff8bfc1f4d __CFRunLoopDoSources0 + 253
12  CoreFoundation                      0x00007fff8bfe8d39 __CFRunLoopRun + 905
13  CoreFoundation                      0x00007fff8bfe8676 CFRunLoopRunSpecific + 230
14  HIToolbox                           0x00007fff829e531f RunCurrentEventLoopInMode + 277
15  HIToolbox                           0x00007fff829ec51b ReceiveNextEventCommon + 181
16  HIToolbox                           0x00007fff829ec456 BlockUntilNextEventMatchingListInMode + 62
17  AppKit                              0x00007fff87bd3f5d _DPSNextEvent + 659
18  AppKit                              0x00007fff87bd3861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
19  libosxapp.dylib                     0x000000011854482c -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 124
20  AppKit                              0x00007fff87bd019d -[NSApplication run] + 470
21  libosxapp.dylib                     0x000000011854474b +[NSApplicationAWT runAWTLoopWithApp:] + 156
22  liblwawt.dylib                      0x00000001184a3ece -[AWTStarter starter:] + 1616
23  CoreFoundation                      0x00007fff8c04375d -[NSObject performSelector:withObject:] + 61
24  Foundation                          0x00007fff845c9d94 __NSThreadPerformPerform + 214
25  CoreFoundation                      0x00007fff8bfc26e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26  CoreFoundation                      0x00007fff8bfc1f4d __CFRunLoopDoSources0 + 253
27  CoreFoundation                      0x00007fff8bfe8d39 __CFRunLoopRun + 905
28  CoreFoundation                      0x00007fff8bfe8676 CFRunLoopRunSpecific + 230
29  java                                0x000000010bd3a4bc CreateExecutionEnvironment + 871
30  java                                0x000000010bd34cac JLI_Launch + 1952
31  java                                0x000000010bd3a819 main + 101
32  java                                0x000000010bd34504 start + 52
33  ???                                 0x0000000000000005 0x0 + 5
)

... and the most important piece of all, the code that invokes all this:

/*  LaserTank: An Arena-Solving Game
Copyright (C) 2008-2010 Eric Ahnell

Any questions should be directed to the author via email at:
*/
package com.puttysoftware.lasertank;

import java.util.ArrayList;

/*import com.puttysoftware.commondialogs.CommonDialogs;
import com.puttysoftware.errorlogger.ErrorLogger;
import com.puttysoftware.lasertank.overridemanagers.OverrideHooks;
import com.puttysoftware.lasertank.overridemanagers.OverrideLoader;
import com.puttysoftware.lasertank.prefs.PreferencesManager;
import com.puttysoftware.platform.Platform;*/

public class LaserTank {

private LaserTank() {
// Do nothing
}

// Constants
private static Application application;
private static final String PROGRAM_NAME = "LaserTank";
private static final String ERROR_MESSAGE = "Perhaps a bug is to blame for this error message.\n"
+ "Include the debug log with your bug report.\n"
+ "Email bug reports to: \n"
+ "Subject: LaserTank Bug Report";
private static final String ERROR_TITLE = "LaserTank Error";
/*private static final ErrorLogger errorLogger = new ErrorLogger(
LaserTank.PROGRAM_NAME);*/

// Methods
/*public static Application getApplication() {
return LaserTank.application;
}

public static ErrorLogger getErrorLogger() {
CommonDialogs.showErrorDialog(ERROR_MESSAGE, ERROR_TITLE);
return LaserTank.errorLogger;
}*/

public static void main(final String[] args) {
try {
// Hook Overrides
// ArrayList<Object> ro = OverrideLoader.loadAllRegisteredOverrides();
// OverrideHooks.injectHooks(ro);
// Integrate with host platform
Platform.hookLAF(LaserTank.PROGRAM_NAME);
// Create and initialize application
// LaserTank.application = new Application();
// LaserTank.application.postConstruct();
// Set Up Common Dialogs
// CommonDialogs.setDefaultTitle(LaserTank.PROGRAM_NAME);
// CommonDialogs.setIcon(LaserTank.application.getMicroLogo());
// Display GUI
// LaserTank.application.getGUIManager().showGUI();
// Register platform hooks
Platform.hookAbout(LaserTank.application.getAboutDialog(),
LaserTank.application.getAboutDialog().getClass()
.getDeclaredMethod("showAboutDialog"));
String s;
if (args.length == 0) {
s = null;
} else {
s = args[0];
}
Platform.hookFileOpen(
LaserTank.application.getArenaManager(),
LaserTank.application
.getArenaManager()
.getClass()
.getDeclaredMethod("loadFromOSHandler",
String.class), s);
Platform.hookPreferences(PreferencesManager.class,
PreferencesManager.class.getDeclaredMethod("showPrefs"));
Platform.hookQuit(LaserTank.application.getGUIManager(),
LaserTank.application.getGUIManager().getClass()
.getDeclaredMethod("quitHandler"));
} catch (Throwable t) {
// LaserTank.getErrorLogger().logError(t);
}
}
}

I commented out stuff that's not relevant to the question at hand, and won't compile anyway due to deliberately omitted code.