This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Gargage collected top-level bindings?
Thanks Per.
I CVS updated this morning. There is one problem I've run into that
is still leading to UnboundLocationExceptions in our code around the
use of define-variable.
I can see it in my test case, too---just define VAR with
"define-variable" like so:
(define-variable VAR 'hello-world)
or see attached. The GC is not relevant in this case.
Dean
Per Bothner wrote:
Per Bothner wrote:
One possible solution is that initializing a top-level binding sets the
default binding rather than the current thread's.
I tried a version of this, and it may be promising. (It fixes Dean's
test-case.)
It's a one-line patch (which I've checked in) to ThreadLocation.java.
When we create a ThreadLocation, we create a default location. This
will be used for all threads that do not override it using fluid-let
(or SRFI-39's parameterize).
Please let me know if this causes any unexpacted behavior.
--- /dev/null Tue Oct 7 04:48:06 2003
+++ Launch.java Mon May 9 14:55:16 2005
@@ -0,0 +1,41 @@
+import java.lang.reflect.*;
+
+public class Launch implements Runnable {
+ public static Launch instance;
+
+ public static void init() {
+ instance = new Launch();
+
+ // Initialize Kawa?
+ // kawa.standard.Scheme.registerEnvironment();
+
+ // Start thread
+ (new Thread(instance)).start();
+
+ // Start thread
+ (new Thread(instance)).start();
+ }
+
+ public void run()
+ {
+ // New thread
+
+ // Initialize Kawa
+ kawa.standard.Scheme.registerEnvironment();
+
+ // Call Kawa module
+ modAFn();
+ }
+
+ public static void modAFn()
+ {
+ // Call into Kawa module
+ try {
+ Class modA = Class.forName("ModA");
+ Method fn = modA.getMethod("fn", null);
+ fn.invoke(null, null);
+ } catch (Throwable e) {
+ System.err.println("modAFn error: " + e);
+ }
+ }
+}
--- /dev/null Tue Oct 7 04:48:06 2003
+++ Start.java Mon May 9 14:46:06 2005
@@ -0,0 +1,8 @@
+import java.lang.reflect.*;
+
+public class Start {
+ public static void main(String[] strings) {
+ // Launch launcher
+ Launch.init();
+ }
+}
--- /dev/null Tue Oct 7 04:48:06 2003
+++ ModA.scm Mon May 9 14:48:50 2005
@@ -0,0 +1,19 @@
+(module-static #t)
+
+(define-variable VAR 'hello-world)
+
+(define (fn)
+ (try-catch
+ (begin
+ (invoke (static-field <java.lang.System> 'err)
+ 'println
+ (format "m: 1, ~A, ~A"
+ (invoke-static <java.lang.Thread> 'currentThread)
+ VAR)))
+ (e <java.lang.Throwable>
+ (invoke (static-field <java.lang.System> 'err)
+ 'println
+ (format "m: Error: ~A, thread: ~A"
+ e
+ (invoke-static <java.lang.Thread> 'currentThread)))
+ (throw e))))