[jboss-svn-commits] JBL Code SVN: r23188 - labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/agent.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 29 12:12:56 EDT 2008


Author: adinn
Date: 2008-09-29 12:12:56 -0400 (Mon, 29 Sep 2008)
New Revision: 23188

Modified:
   labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/agent/RuleAdapter.java
Log:
fixed problem with handler generator code and stack size recomputation

Modified: labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/agent/RuleAdapter.java
===================================================================
--- labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/agent/RuleAdapter.java	2008-09-29 15:52:53 UTC (rev 23187)
+++ labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/agent/RuleAdapter.java	2008-09-29 16:12:56 UTC (rev 23188)
@@ -119,6 +119,11 @@
 
         public void visitEnd()
         {
+            /*
+             * unfortunately, if we generate the handler code here it comes too late for the stack size
+             * computation to take account of it. the handler code uses 4 stack slots so this causes and
+             * error when the method body uses less than 4. we can patch this by generating the handler
+             * code when visitMaxs is called
             Type exceptionType = Type.getType(TypeHelper.externalizeType("org.jboss.jbossts.orchestration.rule.exception.ExecuteException"));
             Type earlyReturnExceptionType = Type.getType(TypeHelper.externalizeType("org.jboss.jbossts.orchestration.rule.exception.EarlyReturnException"));
             Type returnType =  Type.getReturnType(descriptor);
@@ -137,8 +142,36 @@
             }
             super.catchException(startLabel, endLabel, exceptionType);
             super.throwException(exceptionType, rule.getName() + " execution exception ");
+            */
             super.visitEnd();
         }
+
+        public void visitMaxs(int maxStack, int maxLocals) {
+            /*
+             * this really ought to be in visitEnd but see above for why we do it here
+             */
+            Type exceptionType = Type.getType(TypeHelper.externalizeType("org.jboss.jbossts.orchestration.rule.exception.ExecuteException"));
+            Type earlyReturnExceptionType = Type.getType(TypeHelper.externalizeType("org.jboss.jbossts.orchestration.rule.exception.EarlyReturnException"));
+            Type returnType =  Type.getReturnType(descriptor);
+            // add exception handling code subclass first
+            super.catchException(startLabel, endLabel, earlyReturnExceptionType);
+            if (returnType == Type.VOID_TYPE) {
+                // drop exception and just return
+                super.pop();
+                super.visitInsn(Opcodes.RETURN);
+            } else {
+                // fetch value from exception, unbox if needed and return value
+                Method getReturnValueMethod = Method.getMethod("Object getReturnValue()");
+                super.invokeVirtual(earlyReturnExceptionType, getReturnValueMethod);
+                super.unbox(returnType);
+                super.returnValue();
+            }
+            super.catchException(startLabel, endLabel, exceptionType);
+            super.throwException(exceptionType, rule.getName() + " execution exception ");
+            // ok now recompute the stack size
+            super.visitMaxs(maxStack, maxLocals);
+        }
+
     }
 
     private Rule rule;




More information about the jboss-svn-commits mailing list