<AWT Dev> Run AWT on MacOSX with -XstartOnFirstThread

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

<AWT Dev> Run AWT on MacOSX with -XstartOnFirstThread

Langer, Christoph

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

 

Reply | Threaded
Open this post in threaded view
|

Re: <AWT Dev> Run AWT on MacOSX with -XstartOnFirstThread

Sergey Bylokhov
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.
Reply | Threaded
Open this post in threaded view
|

Re: <AWT Dev> Run AWT on MacOSX with -XstartOnFirstThread

Langer, Christoph
Thanks, Sergey, for your response,

I eventually thought so and built a workaround.

Best regards
Christoph

-----Original Message-----
From: Sergey Bylokhov [mailto:[hidden email]]
Sent: Dienstag, 19. Dezember 2017 08:19
To: Langer, Christoph <[hidden email]>; [hidden email]
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:
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.