This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

kawa.repl -C hanging on Mac OS X


I am seeing kawa.repl get stuck when compiling some of my files on Mac OS X.
The trigger appears to be when they load a class with a static block that calls
com.apple.eawt.Application#setDefaultMenuBar(javax.swing.JMenuBar). That spawns
the EDT, but it also does some heavier-weight native Mac stuff. I'm not seeing
the hang with a pure EDT call like
(java.awt.EventQueue:invokeLater (lambda () (format #t "Hello from EDT~ %"))).


When I'm running my application normally, I want this behavior, because Mac app
lifetimes typically aren't tied to the lifetime of a particular window. However,
when it happens during compilation, then my build halts until I manually quit the
kawa.repl program.


I have found two separate fixes, which may or may not affect other Kawa use cases
(and so I offer both):


[1] ModuleBody's exitIncrement/Decrement is supposed to handle this situation for
AWT, and kawa.repl's main() does in fact call ModuleBody.exitDecrement() in a
finally {} block. However, since exitIncrement() was never called, ModuleBody's
exitCounter is still 0, and exitDecrement() is a no-op. This change will make
it call System.exit(0) if exitDecrement() is called when the counter is already 0:



Index: gnu/expr/ModuleBody.java =================================================================== --- gnu/expr/ModuleBody.java (revision 6918) +++ gnu/expr/ModuleBody.java (working copy) @@ -113,10 +113,10 @@ public static synchronized void exitDecrement() { int counter = exitCounter; - if (counter > 0) + if (counter >= 0) { counter--; - if (counter == 0) + if (counter <= 0) { System.exit(0); }


[2] The other solution I've found is to have kawa.repl explicitly call System.exit()
after processArgs returns, like this:
Index: kawa/repl.java
===================================================================
--- kawa/repl.java (revision 6918)
+++ kawa/repl.java (working copy)
@@ -862,6 +862,7 @@
gnu.mapping.OutPort.runCleanups();
}
ModuleBody.exitDecrement();
+ System.exit(0);
}
}


    or this:
Index: kawa/repl.java
===================================================================
--- kawa/repl.java	(revision 6918)
+++ kawa/repl.java	(working copy)
@@ -828,7 +828,7 @@
       {
 	int iArg = processArgs(args, 0, args.length);
 	if (iArg < 0)
-	  return;
+	  System.exit(0);
         boolean ok;
 	if (iArg < args.length)
 	  {


I would lean toward the change in ModuleBody, because it seems consistent
with the intention behind the exit counter for exitDecrement() to call
System.exit() if the counter==0, and not just if it ==1.


Without either change to Kawa, then I have to put a check around my call
to setDefaultMenuBar which first examines a stack trace looking for
kawa.repl.compileFiles(), which seems like a worse hack than the exit
counter.

--
Jamison Hope
The PTR Group
www.theptrgroup.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]