Re: [jnc-users] AttachCurrentThread
Status: Beta
Brought to you by:
soapy
|
From: Marco T. <mt...@gm...> - 2007-09-05 11:40:35
|
Hey Marko
Marko Mocnik wrote:
> Hi!
>
> I am trying to compile a little GUI app with a system tray icon (systray4j).
> The app worked fine with sun java, but not to require a JRE is one of
> my top goals.
Windows? Linux?
AWT? Swing? SWT? You'll be best off with SWT.
> I used the latest release 1.1.1 with gcc-122233-win
> Everything compiled but I ran into two problems:
>
> First:
> Systray4j uses a native thread, which causes trouble.
> These lines:
> ---------------------------------------------------------------
> JDK1_1AttachArgs thread_args;
> s_pVm->AttachCurrentThread( ( void** ) &s_pEnv, &thread_args );
> ---------------------------------------------------------------
> leave me with a NULL Environment.
>
> I did a quick search in the GNU Bugzilla and couldn’t find anything on it.
Directly, I have no idea what could be the reason for this. I think you
should ask this on the GCJ users mailinglist.
> Second:
> Without systray, the app launches.
> But after a while, when I click some buttons or tabs, the GUI Thread
> freezes and the app is no longer responding to anything.
> That freezing can’t be fixed to any action, sometimes it happens even
> before the JFrame is fully visible.
There's probably a thread race respectively wrong synchronized code. The
mingw port of GCJ has a bug that sometimes wait() can be signaled by a
preceding signal().
Now please note the Sun Javadoc of wait:
As in the one argument version, interrupts and spurious wakeups are
possible, and this method should always be used in a loop:
synchronized (obj) {
while (<condition does not hold>)
obj.wait();
... // Perform action appropriate to condition
}
I guess now that your code doesn't loop for the wait and while - luckily
- it never runs into problems with a Sun JRE, GCJs additional bug will
expose the bug in your code.
> I would really appreciate any help here.
I assume you're programming AWT/Swing on Windows. If you want to be rid
of any problems, use SWT. It has built-in support for system tray icons
and SWT is fully supported with JNC/GCJ.
Hope that helps
Marco
> Thanks and bye,
>
> Marko
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> javaCompiler-users mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javacompiler-users
|