diff --git a/classpath/avian/Continuations.java b/classpath/avian/Continuations.java index 814a69b012..2ffb7c7417 100644 --- a/classpath/avian/Continuations.java +++ b/classpath/avian/Continuations.java @@ -195,8 +195,10 @@ public class Continuations { } }); - if (reset.continuation != null) { - reset.continuation.handleResult(result); + Cell shift = reset.shifts; + if (shift != null) { + reset.shifts = shift.next; + shift.value.handleResult(result); } return result; @@ -212,42 +214,41 @@ public class Continuations { return (T) callWithCurrentContinuation(new CallbackReceiver() { public Object receive(final Callback continuation) { final Reset reset = latestReset.get(); - final Callback resetContinuation = reset.continuation; - reset.continuation = new Callback() { + reset.shifts = new Cell(new Callback() { public void handleResult(Object ignored) { try { - resetContinuation.handleResult + reset.continuation.handleResult (receiver.receive (new Function() { public Object call(final Object argument) - throws Exception { - Object result = callWithCurrentContinuation + throws Exception + { + return callWithCurrentContinuation (new CallbackReceiver() { public Object receive (Callback shiftContinuation) throws Exception { - reset.continuation = shiftContinuation; + reset.shifts = new Cell + (shiftContinuation, reset.shifts); + continuation.handleResult(argument); throw new AssertionError(); } }); - - reset.continuation = null; - return result; } })); } catch (Exception e) { - resetContinuation.handleException(e); + reset.continuation.handleException(e); } } public void handleException(Throwable exception) { throw new AssertionError(); } - }; + }, reset.shifts); - resetContinuation.handleResult(null); + reset.continuation.handleResult(null); throw new AssertionError(); } }); @@ -311,9 +312,20 @@ public class Continuations { private static class Reset { public Callback continuation; public final Reset next; + public Cell shifts; public Reset(Reset next) { this.next = next; } } + + private static class Cell { + public final T value; + public final Cell next; + + public Cell(T value, Cell next) { + this.value = value; + this.next = next; + } + } } diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 1dcd9e6769..7e7fd63beb 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -3550,7 +3550,7 @@ boot(Thread* t, uintptr_t*) const char* port = findProperty(t, "avian.trace.port"); if (port) { - object host = makeString(t, "0.0.0.0"); + object host = makeString(t, "localhost"); PROTECT(t, host); object method = resolveMethod diff --git a/test/extra/ComposableContinuations.java b/test/extra/ComposableContinuations.java index b652533960..4af6bd8b8c 100644 --- a/test/extra/ComposableContinuations.java +++ b/test/extra/ComposableContinuations.java @@ -68,8 +68,6 @@ public class ComposableContinuations { } private static boolean equal(Cell a, Cell b) { - System.out.println(a + " vs " + b); - while (a != null) { if (b == null || (! equal(a.car, b.car))) { return false;