You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Art Gramlich <ar...@gramlich-net.com> on 2005/02/21 06:00:04 UTC
[javaflow] Error on empty stack
Below is a quick patch that throws an exception if the stack is empty
when
finishing the execute method in Continuation. I ran into this problem
when
a class was not transformed but called Continuation.suspend. I'm
really new
to this code, but I don't see a way to actually to the alert when the
suspend itself
is called, since in order to find it, I think one would need to
transform the class.
Art Gramlich
Index: org/apache/commons/javaflow/bytecode/Stack.java
===================================================================
--- src/java/org/apache/commons/javaflow/bytecode/Stack.java (revision
154619)
+++ src/java/org/apache/commons/javaflow/bytecode/Stack.java (working
copy)
@@ -249,4 +249,8 @@
",o=" + oTop +
",r=" + rTop;
}
+
+ public boolean isEmpty() {
+ return (iTop == 0 && fTop == 0 && dTop == 0 && lTop == 0 &&
oTop == 0 && rTop == 0);
+ }
}
Index: org/apache/commons/javaflow/Continuation.java
===================================================================
--- src/java/org/apache/commons/javaflow/Continuation.java (revision
154619)
+++ src/java/org/apache/commons/javaflow/Continuation.java (working
copy)
@@ -141,6 +141,9 @@
log.error("could not execute " + continuation, e);
} finally {
if (continuation.capturing) {
+ if (continuation.stack.isEmpty()) {
+ throw new IllegalStateException("The stack is empty.
Perhaps you are calling suspend in a non-continuable class.");
+ }
continuation.stack.popReference();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org