commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Art Gramlich <...@gramlich-net.com>
Subject [javaflow] Error on empty stack
Date Mon, 21 Feb 2005 05:00:04 GMT
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


Mime
View raw message