[jboss-svn-commits] JBL Code SVN: r29364 - in labs/jbosstm/workspace/adinn/byteman/trunk: tests and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 16 05:10:16 EDT 2009
Author: adinn
Date: 2009-09-16 05:10:16 -0400 (Wed, 16 Sep 2009)
New Revision: 29364
Added:
labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/bugfixes/TestThrowAction.txt
labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/bugfixes/TestThrowAction.java
Modified:
labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/expression/ThrowExpression.java
labs/jbosstm/workspace/adinn/byteman/trunk/tests/build.xml
labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/Test.java
Log:
fixed error in compilation of throw actions -- fixes for BYTEMAN-36
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/expression/ThrowExpression.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/expression/ThrowExpression.java 2009-09-16 08:00:30 UTC (rev 29363)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/expression/ThrowExpression.java 2009-09-16 09:10:16 UTC (rev 29364)
@@ -290,10 +290,26 @@
// modify the stack height to account for the removed exception and params
currentStackHeights.addStackCount(-(extraParams+1));
- // we should only have the thrown exception on the stack
if (currentStackHeights.stackCount != currentStack + expected) {
throw new CompileException("ThrowExpression.compile : invalid stack height " + currentStackHeights.stackCount + " expecting " + (currentStack + expected));
}
+ // now create a ThrowException to wrap the user exception
+ // create the thrown exception instance -- adds 1 to stack [UE] --> [UE, THE]
+ exceptionClassName = "org/jboss/byteman/rule/exception/ThrowException";
+ mv.visitTypeInsn(Opcodes.NEW, exceptionClassName);
+ currentStackHeights.addStackCount(1);
+ // copy the ThrowException so we can init it [UE, THE] --> [THE, UE, THE]
+ mv.visitInsn(Opcodes.DUP_X1);
+ currentStackHeights.addStackCount(1);
+ // reverse the order of the top two words [THE, UE, THE] --> [THE, THE, UE]
+ mv.visitInsn(Opcodes.SWAP);
+ // construct the exception [THE, THE, UE] --> [UE]
+ mv.visitMethodInsn(Opcodes.INVOKESPECIAL, exceptionClassName, "<init>", "(Ljava/lang/Throwable;)V");
+ // we should now have just the ThrowException on the stack
+ currentStackHeights.addStackCount(-2);
+ if (currentStackHeights.stackCount != currentStack + expected) {
+ throw new CompileException("ThrowExpression.compile : invalid stack height " + currentStackHeights.stackCount + " expecting " + (currentStack + expected));
+ }
// now throw the exception and decrement the stack height
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/tests/build.xml
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/tests/build.xml 2009-09-16 08:00:30 UTC (rev 29363)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/tests/build.xml 2009-09-16 09:10:16 UTC (rev 29364)
@@ -471,6 +471,27 @@
-->
<test name="org.jboss.byteman.tests.bugfixes.TestMethodParamName"/>
</junit>
+ <junit fork="true" showoutput="true">
+ <classpath>
+ <pathelement location="${build.lib.dir}/byteman-tests.jar"/>
+ <pathelement location="${junit.home}/${junit.jar}"/>
+ </classpath>
+ <jvmarg value="-javaagent:${byteman.home}/${byteman.jar}=script:${scripts.dir}/bugfixes/TestThrowAction.txt"/>
+ <!-- uncomment for verbose byteman output
+ <jvmarg value="-Dorg.jboss.byteman.verbose"/>
+ -->
+ <!-- uncomment to dump generated code
+ <jvmarg value="-Dorg.jboss.byteman.dump.generated.classes"/>
+ <jvmarg value="-Dorg.jboss.byteman.dump.generated.classes.directory=dump"/>
+ -->
+ <!-- uncomment to enable debug
+ <jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xnoagent"/>
+ <jvmarg value="-Djava.compiler=NONE"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=5005"/>
+ -->
+ <test name="org.jboss.byteman.tests.bugfixes.TestThrowAction"/>
+ </junit>
</target>
<target name="tests.bugfixes.compiled">
@@ -543,6 +564,28 @@
-->
<test name="org.jboss.byteman.tests.bugfixes.TestMethodParamName"/>
</junit>
+ <junit fork="true" showoutput="true">
+ <classpath>
+ <pathelement location="${build.lib.dir}/byteman-tests.jar"/>
+ <pathelement location="${junit.home}/${junit.jar}"/>
+ </classpath>
+ <jvmarg value="-javaagent:${byteman.home}/${byteman.jar}=script:${scripts.dir}/bugfixes/TestThrowAction.txt"/>
+ <jvmarg value="-Dorg.jboss.byteman.compileToBytecode"/>
+ <!-- uncomment for verbose byteman output
+ <jvmarg value="-Dorg.jboss.byteman.verbose"/>
+ -->
+ <!-- uncomment to dump generated code
+ <jvmarg value="-Dorg.jboss.byteman.dump.generated.classes"/>
+ <jvmarg value="-Dorg.jboss.byteman.dump.generated.classes.directory=dump"/>
+ -->
+ <!-- uncomment to enable debug
+ <jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xnoagent"/>
+ <jvmarg value="-Djava.compiler=NONE"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=5005"/>
+ -->
+ <test name="org.jboss.byteman.tests.bugfixes.TestThrowAction"/>
+ </junit>
</target>
Copied: labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/bugfixes/TestThrowAction.txt (from rev 29173, labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/bugfixes/TestMethodParamName.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/bugfixes/TestThrowAction.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/bugfixes/TestThrowAction.txt 2009-09-16 09:10:16 UTC (rev 29364)
@@ -0,0 +1,36 @@
+##############################################################################
+# JBoss, Home of Professional Open Source
+# Copyright 2009, Red Hat Middleware LLC, and individual contributors
+# by the @authors tag. See the copyright.txt in the distribution for a
+# full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+# @authors Andrew Dinn
+#
+# Test for BYTEMAN-35 to ensure that a method parameter can be referred to
+# by its local variable name as well as using syntax $0, $1 etc
+
+RULE test use of throw action
+CLASS org.jboss.byteman.tests.bugfixes.TestThrowAction
+METHOD throwMethod
+HELPER org.jboss.byteman.tests.helpers.Default
+AFTER CALL log
+BIND test : TestThrowAction = $0
+IF TRUE
+DO test.log("throwing Exception"),
+ throw Exception("test exception")
+ENDRULE
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/Test.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/Test.java 2009-09-16 08:00:30 UTC (rev 29363)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/Test.java 2009-09-16 09:10:16 UTC (rev 29364)
@@ -79,10 +79,10 @@
String output = getOutput();
String expected = getExpected();
if (!output.equals(expected)) {
- fail("Test " + name + "failed\n" + "\n<expected>\n" + expected + "</expected>\n\n<log>\n" + output +"</log>\n");
+ fail("Test " + name + "failure\n" + "\n<expected>\n" + expected + "</expected>\n\n<log>\n" + output +"</log>\n");
} else {
// System.out.println("Test " + name + " success" + "\n\n<log>\n" + output + "</log>\n");
- System.out.println("Test " + name + " succeeded");
+ System.out.println("Test " + name + " success");
}
if (reset) {
Copied: labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/bugfixes/TestThrowAction.java (from rev 29173, labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/bugfixes/TestMethodParamName.java)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/bugfixes/TestThrowAction.java (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/bugfixes/TestThrowAction.java 2009-09-16 09:10:16 UTC (rev 29364)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*
+* @authors Andrew Dinn
+*/
+package org.jboss.byteman.tests.bugfixes;
+
+import org.jboss.byteman.tests.Test;
+
+/**
+ * Test for BYTEMAN-35 to check that throw actions work.
+ */
+public class TestThrowAction extends Test
+{
+ public TestThrowAction()
+ {
+ super(TestThrowAction.class.getCanonicalName());
+ }
+
+ public void test()
+ {
+ try {
+ throwMethod();
+ } catch (Exception e) {
+ log("caught Exception " + e.getClass());
+ }
+
+ checkOutput();
+ }
+
+ public void throwMethod() throws Exception
+ {
+ log("inside throwMethod()");
+ }
+
+ @Override
+ public String getExpected() {
+ logExpected("inside throwMethod()");
+ logExpected("throwing Exception");
+ logExpected("caught Exception class java.lang.Exception" );
+
+ return super.getExpected();
+ }
+}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list