--- old/src/macosx/native/sun/awt/awt.m 2012-04-05 18:56:36.000000000 +0400 +++ new/src/macosx/native/sun/awt/awt.m 2012-04-05 18:56:36.000000000 +0400 @@ -307,16 +307,18 @@ if (verbose) AWT_DEBUG_LOG(@"got out of the AppKit startup mutex"); } - // Don't set the delegate until the NSApplication has been created and - // its finishLaunching has initialized it. - // ApplicationDelegate is the support code for com.apple.eawt. - void (^setDelegateBlock)() = ^(){ - OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]); - }; - if (onMainThread) { - setDelegateBlock(); - } else { - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:setDelegateBlock]; + if (!headless) { + // Don't set the delegate until the NSApplication has been created and + // its finishLaunching has initialized it. + // ApplicationDelegate is the support code for com.apple.eawt. + void (^setDelegateBlock)() = ^(){ + OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]); + }; + if (onMainThread) { + setDelegateBlock(); + } else { + [JNFRunLoop performOnMainThreadWaiting:YES withBlock:setDelegateBlock]; + } } }