<AWT Dev> Run AWT on MacOSX with -XstartOnFirstThread

Langer, Christoph christoph.langer at sap.com
Tue Dec 19 16:27:13 UTC 2017

Thanks, Sergey, for your response,

I eventually thought so and built a workaround.

Best regards

-----Original Message-----
From: Sergey Bylokhov [mailto:Sergey.Bylokhov at oracle.com] 
Sent: Dienstag, 19. Dezember 2017 08:19
To: Langer, Christoph <christoph.langer at sap.com>; awt-dev at openjdk.java.net
Subject: Re: <AWT Dev> Run AWT on MacOSX with -XstartOnFirstThread

I think it is not possible. The code related to this initialization is 
located in:

+ (void)starter:(BOOL)wasOnMainThread headless:(BOOL)headless {
if (forceEmbeddedMode) {
     AWT_STARTUP_LOG(@"in SWT or SWT/WebStart mode");

     // Init a default NSApplication instance instead of the 
     // Note that [NSApp isRunning] will return YES after that, though
     // this behavior isn't specified anywhere. We rely on that.

if (![app isRunning]) {
     AWT_STARTUP_LOG(@"+[AWTStarter startAWT]: ![app isRunning]");
     // This is where the AWT AppKit thread parks itself to process events.
         [NSApplicationAWT runAWTLoopWithApp: app];
     } else {
// Proceed to exit this call as there is no reason to run the 
NSApplication event loop.

AWT skips initialization of AppKit if it was run using 
"-XstartOnFirstThread" option.

On 07/11/2017 07:39, Langer, Christoph wrote:
> Hi,
> I've got a question to the experts: I have a tool that launches the 
> Eclipse Framework (with SWT). When I start the JVM on MacOSX, I (have 
> to) set the option -XstartOnFirstThread. However, I want to do some work 
> with AWT before launching Eclipse/SWT. But as the AWT NSLoop is not 
> activated in that case, AWT stuff is not working. Is there any chance I 
> can run the AWT NSLoop manually before Swing is active? Is that possible 
> from within Java code? I don't find this topic well documented...
> Thanks in advance for any hints.
> Best regards
> Christoph

Best regards, Sergey.

More information about the awt-dev mailing list