<AWT Dev> Run AWT on MacOSX with -XstartOnFirstThread

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Tue Dec 19 07:19:05 UTC 2017


I think it is not possible. The code related to this initialization is 
located in:
open/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m

+ (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 
NSApplicationAWT.
     // Note that [NSApp isRunning] will return YES after that, though
     // this behavior isn't specified anywhere. We rely on that.
     NSApplicationLoad();
}

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