[jboss-svn-commits] JBL Code SVN: r29698 - in labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1: bin and 25 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 20 11:47:23 EDT 2009
Author: adinn
Date: 2009-10-20 11:47:20 -0400 (Tue, 20 Oct 2009)
New Revision: 29698
Added:
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bmjava.sh
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/build.xml
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ClassLoadMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FileMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FinalizeMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/SocketMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ThreadMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/bugfixes/TestWaitAfterSignalWakeMustMeet.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/TestRecursiveTriggers.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestWaitAfterSignalWakeMustMeet.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/TestWaitAfterSignalWakeMustMeetHelper.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java
Removed:
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover10.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover10.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/build.xml
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ClassLoadMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FileMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FinalizeMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/SocketMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ThreadMonitor.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/TestRecursiveTriggers.txt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java
Modified:
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/README
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bytemancheck.sh
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/submit.sh
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build-release-pkgs.xml
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build.xml
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/docs/ProgrammersGuide.odt
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/docs/ProgrammersGuide.pdf
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Main.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Retransformer.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/RuleScript.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/TransformListener.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Transformer.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/submit/Submit.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/Rule.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/compiler/Compiler.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ArithmeticExpression.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/MethodExpression.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ReturnExpression.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ThrowExpression.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/helper/Helper.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Joiner.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Waiter.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/build.xml
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestEnclosedSynchronizationPropagation.java
labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/Default.java
Log:
merged trunk changes from -r29373 to r29654 into Byteman_1_1
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/README
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/README 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/README 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,8 +1,8 @@
-Byteman 1.0.2 README
+Byteman 1.1.1 README
------------------
Byteman supports injection of side effects into Java programs for the
-purpose of tsting application behaviour.
+purpose of testing application behaviour.
If you have downloaded a binary release then the byteman jar can be found
in
@@ -36,17 +36,38 @@
The agent is passed to the JVM using the -javaagent option of the java
command by setting JAVA_OPTS as follows:
-export JAVA_OPTS="-javaagent:<...>/byteman.jar=script:<...>myscript.txt"
+export JAVA_OPTS="-javaagent:<...>/byteman.jar=script:<...>/myscript.txt"
where the ellipsis <...> is replaced with a suitable path to the jar
and script files.
-The =script:<scriptFile> option to the -javaagent argument tells the
+The script:<scriptFile> option following the '=' separator tells the
agent to search <scriptFile> for rules. Multiple scripts may be
-supplied by repeating the =script:<scriptFile> argument separated by a
-','. The agent will parse each script file to identify rules to be
-triggered from methods occurring in application classes.
+provided by repeating the =script:<scriptFile> argument separated by a
+',' character. The agent parses each of the provided script files to
+identify rules to be triggered from methods occurring in application
+classes.
+Two other options may also be employed, once again using a comma '.'
+character to separate them from preceding options.
+
+The option boot:<jarFile> can be provided to install <jarFile> into
+the bootstrap classloader's search path. This can sometimes be useful
+to ensure that classes employed in rule conditions or actions are
+available when compiling rule code. In particular, when injecting
+side effects into JVM runtime classes which are loaded by the bootstrap
+classloader it is necessary to install the byteman jar using this option.
+
+The option listener:true causes the agent to start a listener thread. This
+thread is used to query the loaded rule base, detecting whether rules have
+been successfully parsed, injected, type-checked or compiled It also allows
+to rule scripts to be uploaded during program execution, either to redefine
+previously loaded rules or add new rules. If a dynamic rule (re)definition
+affects an existing loaded class then the class's methods will be redefined
+so as to inject a trigger call for the newly installed rule. Note that when
+usinf this option (and only in this case) it makes sense to omit the
+script option.
+
By default the rule engine executes rule bindings, conditions and
actions by interpreting the rule parse tree. However, byteman also
supports compiled execution. If system property
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bmjava.sh (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/bin/bmjava.sh)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bmjava.sh (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bmjava.sh 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,193 @@
+#!/bin/bash
+#
+# 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
+#
+# shell script which starts a java program with the byteman
+# agent installed
+#
+# usage: bmjava [-r rulescript | -b bootjar | -s sysjar | -nl | -nb ]* [--] javaargs
+# -r pass the file whose name follows this flag to the agent as
+# a rule script
+#
+# -b pass the file whose name follows this flag to the agent as
+# a jar to be added to the bootstrap classpath
+#
+# -s pass the file whose name follows this flag to the agent as
+# a jar to be added to the system classpath
+#
+# -nl do not enable the agent listener (it is enabled by default)
+#
+# -nb do not add the byteman jar to the bootstrap classpath (it is
+# added by default)
+#
+#
+# -- optional separator to distinguish trailing arguments
+#
+# javaargs trailing arguments to be supplied to the java command
+#
+# The script employs the java command found in the current execution
+# PATH. If BYTEMAN_JAVA_ARGS is set then this is inserted to the
+# java command line before the -javaagent argument and before any
+# arguments in javaargs.
+#
+
+usage()
+{
+cat <<EOF
+usage: bmjava [-l rulescript | -b bootjar | -s sysjar | -nl | -nb | -nj ]* [--] javaargs
+
+terms enclosed between [ ] are optional
+terms separated by | are alternatives
+a * means zero or more occurences
+
+ -l pass the file whose name follows this flag to the agent as
+ a rule script to be loaded during startup
+
+ -b pass the file whose name follows this flag to the agent as
+ a jar to be added to the bootstrap classpath
+
+ -s pass the file whose name follows this flag to the agent as
+ a jar to be added to the system classpath
+
+ -nl do not enable the agent listener (it is enabled by default)
+
+ -nb do not add the byteman jar to the bootstrap classpath (it is
+ added by default)
+
+ -nj do not inject into java.lang classes (it is enabled by default)
+
+ -- optional separator to distinguish trailing arguments
+
+ javaargs trailing arguments to be supplied to the java command
+
+The script constructs a -javaagent argument to pass to the java
+command found in the current execution PATH. If BYTEMAN_JAVA_ARGS
+is set then this is inserted to the java command line before
+the -javaagent argument and before any arguments in javaargs.
+EOF
+exit
+}
+
+# use BYTEMAN_HOME to locate installed byteman release
+if [ -z "$BYTEMAN_HOME" ]; then
+# use the root of the path to this file to locate the byteman jar
+ BYTEMAN_HOME=${0%*/bin/bmjava.sh}
+# allow for rename to plain bmjava
+ if [ "$BYTEMAN_HOME" == "$0" ]; then
+ BYTEMAN_HOME=${0%*/bin/bmjava}
+ fi
+ if [ "$BYTEMAN_HOME" == "$0" ]; then
+ echo "Unable to find byteman home"
+ exit
+ fi
+fi
+
+# the binary release puts byteman jar in lib while source puts it in
+# build/lib so add both paths to the classpath just in case
+if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
+ BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
+elif [ -r ${BYTEMAN_HOME}/build/lib/byteman.jar ]; then
+ BYTEMAN_JAR=${BYTEMAN_HOME}/build/lib/byteman.jar
+else
+ echo "Cannot locate byteman jar"
+ exit
+fi
+AGENT_PREFIX="-javaagent:${BYTEMAN_JAR}"
+AGENT_OPTS=""
+
+# default is to use listener and add byteman jar to bootstrap classpath
+LISTENER=1
+BYTEMAN_BOOT_JAR=1
+INJECT_JAVA_LANG=1
+
+# hmm. the asm code should be bundled in the byteman jar?
+#CP=${CP}:${BYTEMAN_HOME}/ext/asm-all-3.0.jar
+
+while [ $# -ge 1 -a "${1#-*}" != "$1" ]
+do
+ if [ "$1" == "-l" -a $# -ge 2 ]; then
+ if [ -r "$2" ]; then
+ AGENT_OPTS="${AGENT_OPTS},script:$2"
+ shift;
+ shift;
+ else
+ echo "Cannot read script $2"
+ exit
+ fi
+ elif [ "$1" == "-b" -a $# -ge 2 ]; then
+ if [ -r "$2" ]; then
+ AGENT_OPTS="${AGENT_OPTS},boot:$2"
+ shift;
+ shift;
+ else
+ echo "Cannot read boot jar $2"
+ exit
+ fi
+ elif [ "$1" == "-s" -a $# -ge 2 ]; then
+ if [ -r "$2" ]; then
+ AGENT_OPTS="${AGENT_OPTS},sys:$2"
+ shift;
+ shift;
+ else
+ echo "Cannot read system jar $2"
+ exit
+ fi
+ elif [ "$1" == "-nl" ]; then
+ LISTENER=0
+ shift;
+ elif [ "$1" == "-nb" ]; then
+ BYTEMAN_BOOT_JAR=0
+ shift;
+ elif [ "$1" == "-nj" ]; then
+ INJECT_JAVA_LANG=0
+ shift;
+ elif [ "$1" == "--" ]; then
+ shift;
+ break;
+ else
+ # unrecognised option -- must be start of javaargs
+ break
+ fi
+done
+
+if [ $BYTEMAN_BOOT_JAR -eq 1 ]; then
+ AGENT_OPTS="${AGENT_OPTS},boot:${BYTEMAN_JAR}"
+fi
+
+if [ $LISTENER -eq 1 ]; then
+ AGENT_OPTS="listener:true$AGENT_OPTS"
+else
+ AGENT_OPTS="listener:false$AGENT_OPTS"
+fi
+
+if [ $INJECT_JAVA_LANG -eq 1 ]; then
+ INJECT_JAVA_LANG_OPTS="-Dorg.jboss.byteman.quodlibet"
+else
+ INJECT_JAVA_LANG_OPTS=""
+fi
+
+AGENT_ARGUMENT=${AGENT_PREFIX}=${AGENT_OPTS}
+
+# allow for extra java opts via setting BYTEMAN_JAVA_OPTS
+
+exec java ${BYTEMAN_JAVA_OPTS} ${AGENT_ARGUMENT} ${INJECT_JAVA_LANG_OPTS} $*
+
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bytemancheck.sh
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bytemancheck.sh 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/bytemancheck.sh 2009-10-20 15:47:20 UTC (rev 29698)
@@ -25,14 +25,31 @@
#
# usage: bytemancheck -cp classpath script1 . . . scriptN
#
+# use BYTEMAN_HOME to locate installed byteman release
+if [ -z "$BYTEMAN_HOME" ]; then
# use the root of the path to this file to locate the byteman jar
-BASE=${0%*bin/bytemancheck.sh}
+ BYTEMAN_HOME=${0%*/bin/bmjava.sh}
+# allow for rename to plain bmjava
+ if [ "$BYTEMAN_HOME" == "$0" ]; then
+ BYTEMAN_HOME=${0%*/bin/bmjava}
+ fi
+ if [ "$BYTEMAN_HOME" == "$0" ]; then
+ echo "Unable to find byteman home"
+ exit
+ fi
+fi
+
# the binary release puts byteman jar in lib while source puts it in
# build/lib so add both paths to the classpath just in case
-CP=${BASE}lib/byteman.jar
-CP=${BASE}build/lib/byteman.jar
-# hmm. the asm code should be bundled in the byteman jar?
-CP=${CP}:${BASE}ext/asm-all-3.0.jar
+if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
+ BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
+elif [ -r ${BYTEMAN_HOME}/build/lib/byteman.jar ]; then
+ BYTEMAN_JAR=${BYTEMAN_HOME}/build/lib/byteman.jar
+else
+ echo "Cannot locate byteman jar"
+ exit
+fi
+CP=${BYTEMAN_JAR}
# incluide application classes upplied via -cp flag
if [ "$1" == "-cp" ] ; then
CP=${CP}:$2
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/submit.sh
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/submit.sh 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/bin/submit.sh 2009-10-20 15:47:20 UTC (rev 29698)
@@ -22,41 +22,43 @@
# @authors Andrew Dinn
#
# shell script which submits a request to the Byteman agent listener
+# either to list, install or uninstall rule scripts
#
-# usage: submit [script1 . . . scriptN]
+# usage: submit [-l|-u] [script1 . . . scriptN] | [-b | -s] bootjar1 . . .
+# -l (default) install rules in script1 . . . scriptN
+# with no scripts list all installed rules
+# -u uninstall rules in script1 . . . scriptN
+# with no scripts uninstall all installed rules
#
+# -b install jar files bootjar1 etc into bootstrap classpath
+#
+# -s install jar files bootjar1 etc into system classpath
+#
+# use BYTEMAN_HOME to locate installed byteman release
+if [ -z "$BYTEMAN_HOME" ]; then
# use the root of the path to this file to locate the byteman jar
-BASE=${0%*bin/submit.sh}
+ BYTEMAN_HOME=${0%*/bin/bmjava.sh}
+# allow for rename to plain bmjava
+ if [ "$BYTEMAN_HOME" == "$0" ]; then
+ BYTEMAN_HOME=${0%*/bin/bmjava}
+ fi
+ if [ "$BYTEMAN_HOME" == "$0" ]; then
+ echo "Unable to find byteman home"
+ exit
+ fi
+fi
+
# the binary release puts byteman jar in lib while source puts it in
# build/lib so add both paths to the classpath just in case
-CP=${BASE}lib/byteman.jar
-CP=${BASE}build/lib/byteman.jar
-# hmm. the asm code should be bundled in the byteman jar?
-CP=${CP}:${BASE}ext/asm-all-3.0.jar
-
-SCRIPT_OPTS=""
-
-if [ $# -gt 0 -a ${1#-*} != ${1} ]; then
- echo "${1#-*} ${1}"
- echo "usage: submit [script1 . . . scriptN]"
- exit
+if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
+ BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
+elif [ -r ${BYTEMAN_HOME}/build/lib/byteman.jar ]; then
+ BYTEMAN_JAR=${BYTEMAN_HOME}/build/lib/byteman.jar
+else
+ echo "Cannot locate byteman jar"
+ exit
fi
-
-error=0
-while [ $# -ne 0 ]
-do
- if [ ! -f $1 -o ! -r $1 ] ; then
- echo "$1 is not a readable file";
- error=1
- fi
- FILES="${FILES} $1";
- shift
-done
-
-if [ $error -ne 0 ] ; then
- exit
-fi
-
# allow for extra java opts via setting BYTEMAN_JAVA_OPTS
+# Submit class will validate arguments
-java ${BYTEMAN_JAVA_OPTS} -classpath ${CP} org.jboss.byteman.agent.submit.Submit $FILES
+java ${BYTEMAN_JAVA_OPTS} -classpath ${BYTEMAN_JAR} org.jboss.byteman.agent.submit.Submit $*
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build-release-pkgs.xml
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build-release-pkgs.xml 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build-release-pkgs.xml 2009-10-20 15:47:20 UTC (rev 29698)
@@ -72,9 +72,9 @@
http://www.jboss.org/community/docs/DOC-11381 -->
<!--
- <property name="svnbase" value="https://svn.jboss.org/repos/labs/labs/jbosstm/workspace/adinn/byteman/tags"/>
+ <property name="svnbase" value="https://svn.jboss.org/repos/labs/labs/jbosstm/workspace/adinn/byteman"/>
<property name="tag" value="trunk"/>
- <property name="filename" value="1.1.0.SNAPSHOT"/>
+ <property name="filename" value="1.1.1.SNAPSHOT"/>
<property name="mvn.repositoryId" value="snapshots.jboss.org"/>
<property name="mvn.url" value="dav:https://snapshots.jboss.org/maven2"/>
-->
@@ -86,10 +86,10 @@
<property name="svnbase"
value="https://svn.jboss.org/repos/labs/labs/jbosstm/workspace/adinn/byteman/tags"/>
<!-- The tag as it appears under svnbase -->
- <property name="tag" value="Byteman_1_1_0"/>
+ <property name="tag" value="Byteman_1_1_1"/>
<!-- The file name base for the user downloadable files. Derive it
from the tag -->
- <property name="filename" value="1.1.0"/>
+ <property name="filename" value="1.1.1"/>
<!-- the location the Byteman web site content svn is checked out to -->
<property name="cmsdir" value="/home/adinn/jboss/workspace/adinn/byteman/"/>
<!-- the location the maven repository svn is checked out to.
@@ -103,6 +103,7 @@
<target name="init">
<tstamp/>
+ <delete dir="${workdir}"/>
<mkdir dir="${workdir}"/>
</target>
@@ -116,20 +117,13 @@
<!-- package the byteman source release (all src tree) -->
<delete file="${workdir}/byteman-${filename}-src.zip"/>
+
<zip basedir="${workdir}" destfile="${workdir}/byteman-${filename}-src.zip"
includes="${tag}/**"/>
-
- <!-- build the binary release -->
- <delete dir="${workdir}/build"/>
- <mkdir dir="${workdir}/build"/>
- <unzip src="${workdir}/byteman-${filename}-src.zip" dest="${workdir}/build"/>
- <ant dir="${workdir}/build/${tag}" antfile="build.xml" target="install">
+ <!-- build the src and binary release zips -->
+ <ant dir="${workdir}/${tag}" antfile="build.xml" target="zip">
<property name="tag" value="${tag}"/>
</ant>
-
- <!-- package the binary release -->
- <delete file="${workdir}/build/${tag}/build/byteman-${filename}.zip"/>
- <copy toFile="${workdir}/byteman-${filename}.zip" file="${workdir}/build/${tag}/build/byteman.zip"/>
</target>
<!-- copy the release into the cms svn tree (http://www.jboss.org/jbosstm web site content) -->
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build.xml
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build.xml 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/build.xml 2009-10-20 15:47:20 UTC (rev 29698)
@@ -26,20 +26,39 @@
<property name="ext.asm.jars" value="asm-all-3.0.jar"/>
+ <!-- locations for inputs ot build process-->
<property name="src.dir" value="src"/>
- <property name="src.dir.jdk6" value="srcjdk6"/>
+ <property name="bin.src.dir" value="bin"/>
+ <property name="docs.src.dir" value="docs"/>
<property name="dd.dir" value="dd"/>
- <property name="dd.dir.jdk6" value="ddjdk6"/>
<property name="dd.grammar.dir" value="${dd.dir}/grammar"/>
- <property name="ext.lib.dir" value="ext"/>
+ <property name="ext.lib.dir" value="ext"/>
+ <property name="tests.dir" value="tests"/>
+ <property name="tests.src.dir" value="${tests.dir}/src"/>
+ <property name="tests.dd.dir" value="${tests.dir}/dd"/>
+
+ <!-- locations of intermediate build products -->
+
<property name="build.dir" value="build"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="build.lib.dir" value="${build.dir}/lib"/>
- <property name="htdocs.dir" value="htdocs"/>
+ <property name="htdocs.dir" value="htdocs"/>
+ <!-- location of installed build products -->
+ <property name="install.dir" value="install"/>
+ <property name="install.lib.dir" value="${install.dir}/lib"/>
+ <property name="install.bin.dir" value="${install.dir}/bin"/>
+ <property name="install.docs.dir" value="${install.dir}/docs"/>
+
+ <!-- names of specific input and output products -->
+
<property name="ext.jflex.jars" value="JFlex.jar"/>
<property name="ext.javacup.jars" value="javacup.jar"/>
<property name="ext.javacup.rt.jars" value="javacuprt.jar"/>
+ <property name="byteman.jar" value="byteman.jar"/>
+ <property name="byteman.bin.scripts" value="bytemancheck.sh submit.sh bmjava.sh"/>
+ <property name="byteman.doc.files" value="ProgrammersGuide.pdf"/>
+ <property name="manifest.file" value="${dd.dir}/META-INF/MANIFEST.MF"/>
<property name="javac.debug" value="on"/>
@@ -116,54 +135,79 @@
-->
<unjar src="${ext.lib.dir}/javacuprt.jar" dest="${build.classes.dir}"/>
<unjar src="${ext.lib.dir}/asm-all-3.0.jar" dest="${build.classes.dir}"/>
- <jar jarfile="${build.lib.dir}/byteman.jar" manifest="${dd.dir}/META-INF/MANIFEST.MF">
+ <jar jarfile="${build.lib.dir}/${byteman.jar}" manifest="${manifest.file}">
<fileset dir="${build.classes.dir}" includes="**/*"/>
</jar>
</target>
- <target name="install" depends="jar">
- <zip destfile="${build.dir}/byteman.zip">
- <fileset dir="${build.dir}" includes="lib/byteman.jar"/>
- <fileset dir="." includes="README"/>
- <fileset dir="." includes="docs/ProgrammersGuide.pdf"/>
- <fileset dir="." includes="bin/bytemancheck.sh bin/submit.sh"/>
- <fileset dir="." includes="ext/asm-all-3.0.jar"/>
- <fileset dir="." includes="ext/third_party_licenses.txt"/>
- </zip>
+ <!-- installation targets -->
+ <target name="init-install">
+ <delete dir="${install.dir}"/>
+ <mkdir dir="${install.dir}"/>
+ <mkdir dir="${install.lib.dir}"/>
+ <mkdir dir="${install.bin.dir}"/>
+ <mkdir dir="${install.docs.dir}"/>
</target>
- <target name="install-src" depends="htdocs">
- <zip destfile="${build.dir}/byteman-src.zip">
- <fileset dir="." includes="README build.xml"/>
- <fileset dir="${build.dir}" includes="lib/byteman.jar"/>
- <fileset dir="." includes="src/**/*" excludes="src/**/.svn/**/*"/>
- <fileset dir="." includes="docs/**" excludes="docs/**/.svn/**/*"/>
- <fileset dir="." includes="htdocs/**" excludes="docs/**/.svn/**/*"/>
- <fileset dir="." includes="bin/**" excludes="bin/**/.svn/**/*"/>
- <fileset dir="." includes="ext/**" excludes="ext/**/.svn/**/*"/>
- <fileset dir="." includes="dd/**" excludes="dd/**/.svn/**/*"/>
- <fileset dir="." includes="tests/build.xml"/>
- <fileset dir="." includes="tests/src/**/*" excludes="tests/src/**/.svn/**/*"/>
- <fileset dir="." includes="tests/dd/**/*" excludes="tests/sdd/**/.svn/**/*"/>
+ <target name="local-install">
+ <copy todir="${install.lib.dir}">
+ <fileset dir="${build.lib.dir}" includes="${byteman.jar}"/>
+ </copy>
+ <copy todir="${install.bin.dir}">
+ <fileset dir="${bin.src.dir}" includes="${byteman.bin.scripts}"/>
+ </copy>
+ <copy todir="${install.docs.dir}">
+ <fileset dir="${docs.src.dir}" includes="${byteman.doc.files}"/>
+ </copy>
+ </target>
+
+ <!-- target to make and install samples in samples directory -->
+ <target name="sample-install">
+ <ant dir="sample" target="install"/>
+ </target>
+
+ <target name="install" depends="jar, init-install, local-install, sample-install">
+ </target>
+
+ <!-- target for use by build-release-pkgs script n.b. this assumes it is being run in a clean
+ source tree under tags obtained using svn export. -->
+ <target name="zip" depends="install">
+ <zip destfile="${build.dir}/byteman.zip">
+ <fileset dir="${install.dir}" includes="**/*"/>
</zip>
+ <zip destfile="${build.dir}/byteman-src.zip">
+ <fileset dir="${install.dir}" includes="**/*"/>
+ <fileset dir="." includes="${src.dir}/**/*"/>
+ <fileset dir="." includes="${dd.dir}/**/*"/>
+ <fileset dir="." includes="${docs.src.dir}/**/*"/>
+ <fileset dir="." includes="${htdocs.dir}/**/*"/>
+ <fileset dir="." includes="${bin.src.dir}/**/*"/>
+ <fileset dir="." includes="${ext.lib.dir}/**/*"/>
+ <fileset dir="." includes="${tests.src.dir}/**/*"/>
+ <fileset dir="." includes="${tests.dd.dir}/**/*"/>
+ </zip>
</target>
+ <!-- target to make htdocs for byteman code -->
<target name="htdocs">
<delete dir="${htdocs.dir}"/>
<mkdir dir="${htdocs.dir}"/>
- <javadoc packagenames="org.jboss.byteman" destdir="${htdocs.dir}" linksource="true" private="true">
+ <javadoc packagenames="org.jboss.byteman" destdir="${htdocs.dir}" private="true">
<classpath>
<fileset dir="${ext.lib.dir}" includes="${ext.asm.jars}"/>
<fileset dir="${ext.lib.dir}" includes="${ext.javacup.jars}"/>
<fileset dir="${ext.lib.dir}" includes="${ext.javacup.rt.jars}"/>
</classpath>
<fileset dir="${src.dir}" includes="**/*.java"/>
- <fileset dir="${src.dir.jdk6}" includes="**/*.java"/>
</javadoc>
</target>
- <target name="clean">
- <delete dir="${build.dir}"/>
- <delete dir="${dd.grammar.dir}" includes="*.java *.tokens"/>
- </target>
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ <delete dir="${dd.grammar.dir}" includes="*.java *.tokens"/>
+ </target>
+
+ <target name="spotless" depends="clean">
+ <delete dir="${install.dir}"/>
+ </target>
</project>
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,235 +0,0 @@
-##############################################################################
-# JBoss, Home of Professional Open Source
-# Copyright 2008, 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
-#
-# Heuristic Recovery After Delayed Commit in Single JVM
-#
-# This script automates testing of a specific recovery scenario for the
-# JBossTS XTS implementation of the WS-AT 1.1 protocol using byteman
-# rules. The scenario is as follows:
-#
-# AS boots
-# Client starts a WS-AT transaction
-# Client invokes web service 1
-# Web service 1 registers as participant P1
-# Client invokes web service 2
-# Web service 2 registers as participant P2
-# Client commits WS-AT transaction
-# Coordinator initiates commit of participant P1
-# ** Rule system intercepts commit and crahses JVM
-#
-# AS reboots
-# Recovery system starts after 2 minutes
-# Recovery system recreates PREPARED WS-AT transaction coordinator
-# Recovery system recreates participant stub for P1
-# ** Rule system adds countdown(2) for P1
-# Recovery system recreates participant stub for P2
-# ** Rule system adds countdown for P2
-# Recovery system calls replay of PREPARED transaction
-# ** Rule system traces PREPARED replay invocation
-# Coordinator sends commit to P1
-# ** Rule system decrements P1's countdown to 1
-#
-# P1 replies with committed
-# ** Rule system intercepts committed message handler and aborts thread
-#
-# Coordinator sends commit to P2
-# ** Rule system decrements P2's countdown to 1
-# (last 2 steps repeated while countdown is active)
-#
-# P2 replies with committed
-# ** Rule system intercepts committed message handler and aborts thread
-# (last 2 steps repeated while countdown is active)
-#
-# Coordinator times out commit and writes heuristic transaction to log
-# Recovery system sleeps
-
-# Recovery system restarts after 2 minutes
-# Recovery system recreates HEURISTIC WS-AT transaction coordinator
-# Recovery system detects existing participant stub for P1
-# Recovery system detects existing participant stub for P2
-#
-# Coordinator sends commit to P1
-# ** Rule system decrements P1's countdown to 0 and removes countdown
-# P1 replies with committed
-# Coordinator sends commit to P2
-# ** Rule system decrements P2's countdown to 0 and removes countdown
-# P2 replies with committed
-# Coordinator clears heuristic log record and copletes commit
-# ** Rule system detects completed commit and kills JVM
-#
-# The number of participants must be at least 2 but can actually be
-# more. One way of exercising the test is to start the AS and run the
-# XTS demo. It should crash at the point of commit. At reboot the
-# rest of the test shoudl run automatically and the server should be
-# killed after a the heuristic transaction is successfuly killed. The
-# console (or server) log should contain messages indicating replays of
-# the prepared and then the heuristic transactions and then a message
-# indicating that the heuristic transacton has committed.
-
-#######################################################################
-# This rule is triggered when a participant stub (CoordinatorEngine) is
-# created from details located in the log record. It adds a countdown
-# which is tripped each time a commit is tried on the participant.
-# While the countdown is active committed messages will be blocked.
-# Note that it calls isRecovered() to detect that the stub has been
-# recreated from the log.
-# The line number is the trigger point is after assignment of all
-# the instance's fields ensuring the rule can safely test them.
-
-RULE add coordinator engine countdown
-CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
-METHOD <init>(String, boolean, W3CEndpointReference, boolean, State)
-AFTER WRITE recovered
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
-DO debug("adding countdown for " + identifier),
- addCountDown(identifier, 1)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when a non-recovered participant stub
-# (CoordinatorEngine) is sent a commit message i.e. immediately
-# after a successful prepare. It exits the JVM, simulating a crash.
-# The trigger point is at the start of the method
-
-RULE kill JVM
-CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
-METHOD commit
-AT ENTRY
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF (NOT recovered)
- AND
- debug("commit on non-recovered engine " + identifier)
-DO debug("!!!killing JVM!!!"),
- killJVM()
-ENDRULE
-
-#######################################################################
-# This rule is triggered when a recovered participant stub
-# (CoordinatorEngine) is sent a commit message i.e. immediately
-# after a successful prepare. It decrements the countdown. First
-# time round this takes it from 1 to 0 but leaves it in place. Second
-# time round it removes it allowing committed messages to flow.
-# The trigger point is at the start of the method.
-
-RULE countdown at commit
-CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
-METHOD commit
-AT ENTRY
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
- AND
- debug("commit on recovered engine " + identifier)
- AND
- debug("counting down")
- AND
- countDown(identifier)
-DO debug("countdown completed for " + identifier)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when a recovered participant stub
-# (CoordinatorEngine) is sent a committed message i.e. in the handler
-# thread which responds to a COMMITTED message from a participant.
-# If it detects a countdown registered using the participant id it
-# throws a runtime exception causing the thread to abort and stopping
-# delivery of the COMMITTED message. The trigger point is at the start
-# of the method.
-
-RULE kill committed thread
-CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
-METHOD committed(Notification, AddressingProperties, ArjunaContext)
-AT ENTRY
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
- AND
- debug("committed on recovered engine " + identifier)
- AND
- getCountDown(identifier)
-DO debug("!!!killing committed thread for " + identifier + "!!!"),
- return
-ENDRULE
-
-#######################################################################
-# This rule is triggered when the recovery system finds the PREPARED
-# transaction in the log and reruns the phase 2 commit operation.
-# It prints a message which can be used to verify that the test has
-# worked correctly. The trigger point is at the call to phase2Commit.
-
-RULE trace prepared replay
-CLASS org.jboss.jbossts.xts.recovery.RecoverACCoordinator
-METHOD replayPhase2
-AT INVOKE phase2Commit
-BIND coordinator = $0,
- uid : Uid = coordinator.identifier(),
- status : int = coordinator.status()
-IF (status == com.arjuna.ats.arjuna.coordinator.ActionStatus.PREPARED)
- OR
- (status == com.arjuna.ats.arjuna.coordinator.ActionStatus.COMMITTING)
-DO debug("replaying commit for prepared transaction " + uid)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when the recovery system finds the COMMITTED
-# transaction in the log and reruns the phase 2 commit operation.
-# It prints a message which can be used to verify that the test has
-# worked correctly. The trigger point is at the call to phase2Commit.
-
-RULE trace heuristic committed replay
-CLASS org.jboss.jbossts.xts.recovery.RecoverACCoordinator
-METHOD replayPhase2
-AT INVOKE phase2Commit
-BIND coordinator = $0,
- uid : Uid = coordinator.identifier(),
- status : int = coordinator.status()
-IF status == com.arjuna.ats.arjuna.coordinator.ActionStatus.COMMITTED
-DO debug("replaying commit for heuristic committed transaction " + uid)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when the recovery system deletes the COMMITTED
-# transaction from the log. It prints a message which can be used to
-# verify that the test has worked correctly. It also kills the JVM to
-# halt the test. The trigger point is on return from the call to
-# remove_committed, ensuring that the log is cleaned up before the exit
-# takes place
-
-RULE trace remove committed state
-CLASS com.arjuna.ats.arjuna.coordinator.BasicAction
-METHOD updateState
-AFTER INVOKE remove_committed
-BIND action : BasicAction = $0,
- uid = action.get_uid()
-IF TRUE
-DO debug("removed committed transaction " + uid),
- debug("!!!killing JVM!!!"),
- killJVM()
-ENDRULE
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover10.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover10.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/HeuristicSaveAndRecover10.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,234 +0,0 @@
-##############################################################################
-# JBoss, Home of Professional Open Source
-# Copyright 2008, 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
-#
-# Heuristic Recovery After Delayed Commit in Single JVM
-#
-# This script automates testing of a specific recovery scenario for the
-# JBossTS XTS implementation of the WS-AT 1.0 protocol using byteman
-# rules. The scenario is as follows:
-#
-# AS boots
-# Client starts a WS-AT transaction
-# Client invokes web service 1
-# Web service 1 registers as participant P1
-# Client invokes web service 2
-# Web service 2 registers as participant P2
-# Client commits WS-AT transaction
-# Coordinator initiates commit of participant P1
-# ** Rule system intercepts commit and crahses JVM
-#
-# AS reboots
-# Recovery system starts after 2 minutes
-# Recovery system recreates PREPARED WS-AT transaction coordinator
-# Recovery system recreates participant stub for P1
-# ** Rule system adds countdown(2) for P1
-# Recovery system recreates participant stub for P2
-# ** Rule system adds countdown for P2
-# Recovery system calls replay of PREPARED transaction
-# ** Rule system traces PREPARED replay invocation
-# Coordinator sends commit to P1
-# ** Rule system decrements P1's countdown to 1
-#
-# P1 replies with committed
-# ** Rule system intercepts committed message handler and aborts thread
-#
-# Coordinator sends commit to P2
-# ** Rule system decrements P2's countdown to 1
-# (last 2 steps repeated while countdown is active)
-#
-# P2 replies with committed
-# ** Rule system intercepts committed message handler and aborts thread
-# (last 2 steps repeated while countdown is active)
-#
-# Coordinator times out commit and writes heuristic transaction to log
-# Recovery system sleeps
-
-# Recovery system restarts after 2 minutes
-# Recovery system recreates HEURISTIC WS-AT transaction coordinator
-# Recovery system detects existing participant stub for P1
-# Recovery system detects existing participant stub for P2
-#
-# Coordinator sends commit to P1
-# ** Rule system decrements P1's countdown to 0 and removes countdown
-# P1 replies with committed
-# Coordinator sends commit to P2
-# ** Rule system decrements P2's countdown to 0 and removes countdown
-# P2 replies with committed
-# Coordinator clears heuristic log record and copletes commit
-# ** Rule system detects completed commit and kills JVM
-#
-# The number of participants must be at least 2 but can actually be
-# more. One way of exercising the test is to start the AS and run the
-# XTS demo. It should crash at the point of commit. At reboot the
-# rest of the test shoudl run automatically and the server should be
-# killed after a the heuristic transaction is successfuly killed. The
-# console (or server) log should contain messages indicating replays of
-# the prepared and then the heuristic transactions and then a message
-# indicating that the heuristic transacton has committed.
-
-#######################################################################
-# This rule is triggered when a participant stub (CoordinatorEngine) is
-# created from details located in the log record. It adds a countdown
-# which is tripped each time a commit is tried on the participant.
-# While the countdown is active committed messages will be blocked.
-# Note that it calls isRecovered() to detect that the stub has been
-# recreated from the log.
-# The trigger point follows all the field assignments, ensuring that they
-# can be read by the rule.
-
-RULE add coordinator engine countdown
-CLASS com.arjuna.wst.messaging.engines.CoordinatorEngine
-METHOD <init>(String, boolean, EndpointReferenceType, boolean, State)
-AFTER WRITE recovered
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
-DO debug("adding countdown for " + identifier),
- addCountDown(identifier, 1)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when a non-recovered participant stub
-# (CoordinatorEngine) is sent a commit message i.e. immediately
-# after a successful prepare. It exits the JVM, simulating a crash.
-# The trigger point is the first line.
-
-RULE kill JVM
-CLASS com.arjuna.wst.messaging.engines.CoordinatorEngine
-METHOD commit
-AT ENTRY
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF (NOT recovered)
- AND
- debug("commit on non-recovered engine " + identifier)
-DO debug("!!!killing JVM!!!"),
- killJVM()
-ENDRULE
-
-#######################################################################
-# This rule is triggered when a recovered participant stub
-# (CoordinatorEngine) is sent a commit message i.e. immediately
-# after a successful prepare. It decrements the countdown. First
-# time round this takes it from 1 to 0 but leaves it in place. Second
-# time round it removes it allowing committed messages to flow.
-# The trigger point is the first line.
-
-RULE countdown at commit
-CLASS com.arjuna.wst.messaging.engines.CoordinatorEngine
-METHOD commit
-AT ENTRY
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
- AND
- debug("commit on recovered engine " + identifier)
- AND
- debug("counting down")
- AND
- countDown(identifier)
-DO debug("countdown completed for " + identifier)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when a recovered participant stub
-# (CoordinatorEngine) is sent a committed message i.e. in the handler
-# thread which responds to a COMMITTED message from a participant.
-# If it detects a countdown registered using the participant id it
-# throws a runtime exception causing the thread to abort and stopping
-# delivery of the COMMITTED message. The trigger point is the first
-# line.
-
-RULE kill committed thread
-CLASS com.arjuna.wst.messaging.engines.CoordinatorEngine
-METHOD committed(NotificationType, AddressingContext, ArjunaContext)
-AT ENTRY
-BIND engine:CoordinatorEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
- AND
- debug("committed on recovered engine " + identifier)
- AND
- getCountDown(identifier)
-DO debug("!!!killing committed thread for " + identifier + "!!!"),
- return
-ENDRULE
-
-#######################################################################
-# This rule is triggered when the recovery system finds the PREPARED
-# transaction in the log and reruns the phase 2 commit operation.
-# It prints a message which can be used to verify that the test has
-# worked correctly. The trigger point is the call to phase2Commit.
-
-RULE trace prepared replay
-CLASS org.jboss.jbossts.xts.recovery.RecoverACCoordinator
-METHOD replayPhase2
-AT INVOKE phase2Commit
-BIND coordinator = $0,
- uid : Uid = coordinator.identifier(),
- status : int = coordinator.status()
-IF (status == com.arjuna.ats.arjuna.coordinator.ActionStatus.PREPARED)
- OR
- (status == com.arjuna.ats.arjuna.coordinator.ActionStatus.COMMITTING)
-DO debug("replaying commit for prepared transaction " + uid)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when the recovery system finds the COMMITTED
-# transaction in the log and reruns the phase 2 commit operation.
-# It prints a message which can be used to verify that the test has
-# worked correctly. The trigger point is the call to phase2Commit.
-
-RULE trace heuristic committed replay
-CLASS org.jboss.jbossts.xts.recovery.RecoverACCoordinator
-METHOD replayPhase2
-AT INVOKE phase2Commit
-BIND coordinator = $0,
- uid : Uid = coordinator.identifier(),
- status : int = coordinator.status()
-IF status == com.arjuna.ats.arjuna.coordinator.ActionStatus.COMMITTED
-DO debug("replaying commit for heuristic committed transaction " + uid)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when the recovery system deletes the COMMITTED
-# transaction from the log. It prints a message which can be used to
-# verify that the test has worked correctly. It also kills the JVM to
-# halt the test. The trigger point is after return from the call to
-# remove_committed, ensuring that the lgo is cleaned up before exit.
-
-RULE trace remove committed state
-CLASS com.arjuna.ats.arjuna.coordinator.BasicAction
-METHOD updateState
-AFTER INVOKE remove_committed
-BIND action : BasicAction = $0,
- uid = action.get_uid()
-IF TRUE
-DO debug("removed committed transaction " + uid),
- debug("!!!killing JVM!!!"),
- killJVM()
-ENDRULE
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,176 +0,0 @@
-##############################################################################
-# JBoss, Home of Professional Open Source
-# Copyright 2008, 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
-#
-# Participant Recovery with Remote Coordinator
-#
-# This script automates testing of a specific recovery scenario for the
-# JBossTS XTS implementation of the WS-AT 1.1 protocol using byteman
-# rules. The scenario is as follows:
-#
-# AS1 boots
-# AS2 boots
-# AS1 Client starts a WS-AT transaction talking to coordinator in AS2
-# AS1 Client invokes web service 1
-# AS1 Web service 1 registers as participant P1
-# AS1 Client invokes web service 2
-# AS1 Web service 2 registers as participant P2
-# AS1 Client commits WS-AT transaction
-#
-# AS2 Coordinator initiates commit of participant P1
-# AS2 Coordinator sends commit to P1
-#
-# AS1 P1 receives commit
-# ** AS1 Rule system intercepts commit and crashes JVM
-#
-# AS2 Coordinator attempts to resend message
-# ** AS2 Rule system suspends coordinator waiting on incoming prepared
-# message from P1
-# (commit messages continue to be resent in the meantime)
-#
-# AS1 reboots
-# AS1 Recovery system starts after 2 minutes
-# AS1 Recovery system recreates PREPARED WS-AT participant P1
-# ** AS1 Rule system traces recreate
-# AS1 Participant P1 resends prepared
-# AS1 Participant P1 receives commit for P1
-# AS1 Participant P1 sends committed
-#
-# AS2 Participant stub receives committed message for P1
-# ** AS2 Rule system signals coordinator clearing wait
-# ** AS2 rule system traces receipt of committed message for P1
-#
-# AS2 Coordinator detects committed from P1
-# AS2 Coordinator sends commit for P2
-# AS2 Coordinator receives committed from P2
-# AS2 Coordinator completes transaction
-# ** AS2 Rule system traces successful completion
-#
-# One way of exercising the test is to start the ASes and run the XTS
-# demo in one AS using a remote coordinator in the othher AS. It should
-# crash at the point of commit. At reboot the rest of the test should
-# run automatically and the server should be killed after a the
-# transaction is successfuly terminated. The console (or server)
-# log should contain messages indicating replays of the prepared and
-# then the heuristic transactions and then a message indicating that the
-# heuristic transacton has committed.that the participant server (AS1)
-# has crashed and then restarted.
-
-#
-# !!! N.B. this test currently fails because JBossWS Native fails to cope
-# !!! with requests for services while they are bootstrapping
-#
-
-######################################################################
-# AS1 Rule set
-#######################################################################
-# This rule is triggered in the AS1 when a non-recovered WS-AT
-# participant receives a commit message. It causes the JVM to crash.
-# The trigger point is the start of the method.
-
-RULE crash unrecovered participant at commit
-CLASS com.arjuna.wst11.messaging.engines.ParticipantEngine
-METHOD commit
-AT ENTRY
-BIND engine:ParticipantEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF (NOT recovered)
- AND
- debug("commit on non-recovered participant engine " + identifier)
-DO debug("!!!killing JVM!!!"),
- killJVM()
-ENDRULE
-
-#######################################################################
-# This rule is triggered in the AS1 when a recovered WS-AT participant
-# is recreated from the log. It traces the call to allow success of the
-# test to be detected.
-# The trigger point is the end of the constructor so that the rule can
-# safely read all the fields.
-
-RULE trace recovered participant recreate
-CLASS com.arjuna.wst11.messaging.engines.ParticipantEngine
-METHOD <init>(Participant, id, State, W3CEndpointReference, boolean)
-AFTER WRITE persisted
-BIND engine:ParticipantEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
-DO debug("recreated recovered participant engine " + identifier)
-ENDRULE
-
-
-######################################################################
-# AS2 Rule set
-######################################################################
-# This rule is triggered in AS2 when a participant stub
-# (CoordinatorEngine) first posts a commit message to the participant.
-# The coordinator thread suspends until a committed message is received
-# from the participant. This ensures that it waits until AS1
-# has restarted allowing the transaction to then complete. The
-# condition tests whether a flag with key "firstCommit" has been set.
-# By default this is clear so the condition is true first time the
-# rule is called. The action sets te flag causing the condition to
-# evaluate to false on subsequent commit calls.
-# The trigger point is just before calling waitForState.
-
-RULE suspend coordinator after sending first commit
-CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
-METHOD commit
-LINE 330
-BIND engine:CoordinatorEngine = $0,
- identifier:String = engine.getId()
-IF (NOT flagged("firstCommit"))
-DO debug("coordinator waiting for participant to resend prepare" + identifier),
- flag("firstCommit"),
- waitFor(identifier)
-ENDRULE
-
-#######################################################################
-
-# This rule is triggered when a committed message is received from P1.
-# This indicates that the participant has been recreated and
-# successfully responded to a commit message after reboot of AS1. The
-# rule uses a call to signal to wake up the coordinator which was
-# suspended when the first commit was sent. This call only returns true
-# if the identifier is for P1 and the coordinator has not already been
-# signalled. Note that the call to signal is made in the condition to
-# avoid a race between threads handling successive committed messages.
-# If instead the condition called waiting() and the action called
-# signal() then, depending upon scheduling, both threads might find the
-# condition to be true before one of them could execute signal().
-# Although this would be harmless in this case it could be significant
-# when using other rules.
-# The triogger point is at the sttart of the method.
-
-RULE signal waiting coordinator
-CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
-METHOD committed
-AT ENTRY
-BIND engine : CoordinatorEngine = $0,
- identifier:String = engine.getId()
-IF debug("received committed for participant " + identifier)
- AND
- signal(identifier)
-DO debug("signalled coordinator waiting on " + identifier)
-ENDRULE
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover10.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover10.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/dd/scripts/ParticipantCrashAndRecover10.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,174 +0,0 @@
-##############################################################################
-# JBoss, Home of Professional Open Source
-# Copyright 2008, 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
-#
-# Participant Recovery with Remote Coordinator
-#
-# This script automates testing of a specific recovery scenario for the
-# JBossTS XTS implementation of the WS-AT 1.0 protocol using byteman
-# rules. The scenario is as follows:
-#
-# AS1 boots
-# AS2 boots
-# AS1 Client starts a WS-AT transaction talking to coordinator in AS2
-# AS1 Client invokes web service 1
-# AS1 Web service 1 registers as participant P1
-# AS1 Client invokes web service 2
-# AS1 Web service 2 registers as participant P2
-# AS1 Client commits WS-AT transaction
-#
-# AS2 Coordinator initiates commit of participant P1
-# AS2 Coordinator sends commit to P1
-#
-# AS1 P1 receives commit
-# ** AS1 Rule system intercepts commit and crashes JVM
-#
-# AS2 Coordinator attempts to resend message
-# ** AS2 Rule system suspends coordinator waiting on incoming prepared
-# message from P1
-# (commit messages continue to be resent in the meantime)
-#
-# AS1 reboots
-# AS1 Recovery system starts after 2 minutes
-# AS1 Recovery system recreates PREPARED WS-AT participant P1
-# ** AS1 Rule system traces recreate
-# AS1 Participant P1 resends prepared
-# AS1 Participant P1 receives commit for P1
-# AS1 Participant P1 sends committed
-#
-# AS2 Participant stub receives committed message for P1
-# ** AS2 Rule system signals coordinator clearing wait
-# ** AS2 rule system traces receipt of committed message for P1
-#
-# AS2 Coordinator detects committed from P1
-# AS2 Coordinator sends commit for P2
-# AS2 Coordinator receives committed from P2
-# AS2 Coordinator completes transaction
-# ** AS2 Rule system traces successful completion
-#
-# One way of exercising the test is to start the ASes and run the XTS
-# demo in one AS using a remote coordinator in the othher AS. It should
-# crash at the point of commit. At reboot the rest of the test should
-# run automatically and the server should be killed after a the
-# transaction is successfuly terminated. The console (or server)
-# log should contain messages indicating replays of the prepared and
-# then the heuristic transactions and then a message indicating that the
-# heuristic transacton has committed.that the participant server (AS1)
-# has crashed and then restarted.
-
-######################################################################
-# AS1 Rule set
-#######################################################################
-# This rule is triggered in the AS1 when a non-recovered WS-AT
-# participant receives a commit message. It causes the JVM to crash.
-# The trigger point is at the start of the call.
-
-RULE crash unrecovered participant at commit
-CLASS com.arjuna.wst.messaging.engines.ParticipantEngine
-METHOD commit
-AT ENTRY
-BIND engine:ParticipantEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF (NOT recovered)
- AND
- debug("commit on non-recovered participant engine " + identifier)
-DO debug("!!!killing JVM!!!"),
- killJVM()
-ENDRULE
-
-#######################################################################
-# This rule is triggered in the AS1 when a recovered WS-AT participant
-# is recreated from the log. It traces the call to allow success of the
-# test to be detected.
-# The trigger point is at teh end of the field writes so that the rule
-# can safely read them.
-
-RULE trace recovered participant recreate
-CLASS com.arjuna.wst.messaging.engines.ParticipantEngine
-METHOD <init>(Participant, String, State, EndpointReferenceType, boolean)
-AFETR WRITE persisted
-BIND engine:ParticipantEngine = $0,
- recovered:boolean = engine.isRecovered(),
- identifier:String = engine.getId()
-IF recovered
-DO debug("recreated recovered participant engine " + identifier)
-ENDRULE
-
-
-######################################################################
-# AS2 Rule set
-######################################################################
-# This rule is triggered in AS2 when a participant stub
-# (CoordinatorEngine) first posts a commit message to the participant.
-# The coordinator thread suspends until a committed message is received
-# from the participant. This ensures that it waits until AS1
-# has restarted allowing the transaction to then complete. The
-# condition tests whether a flag with key "firstCommit" has been set.
-# By default this is clear so the condition is true first time the
-# rule is called. The action sets te flag causing the condition to
-# evaluate to false on subsequent commit calls.
-# The triggger point is immediately before the call to waitForState.
-
-RULE suspend coordinator after sending first commit
-CLASS com.arjuna.wst.messaging.engines.CoordinatorEngine
-METHOD commit
-AT INVOKE waitForState
-BIND engine:CoordinatorEngine = $0,
- identifier:String = engine.getId()
-IF (NOT flagged("firstCommit"))
-DO debug("coordinator waiting for participant to resend prepare" + identifier),
- flag("firstCommit"),
- waitFor(identifier),
- debug("coordinator finished waiting for participant to resend prepare" + identifier)
-ENDRULE
-
-#######################################################################
-# This rule is triggered when a committed message is received from P1.
-# This indicates that the participant has been recreated and
-# successfully responded to a commit message after reboot of AS1. The
-# rule uses a call to signal to wake up the coordinator which was
-# suspended when the first commit was sent. This call only returns true
-# if the identifier is for P1 and the coordinator has not already been
-# signalled. Note that the call to signal is made in the condition to
-# avoid a race between threads handling successive committed messages.
-# If instead the condition called waiting() and the action called
-# signal() then, depending upon scheduling, both threads might find the
-# condition to be true before one of them could execute signal().
-# Although this would be harmless in this case it could be significant
-# when using other rules.
-# The trigger point is the start of th method.
-
-RULE signal waiting coordinator
-CLASS com.arjuna.wst.messaging.engines.CoordinatorEngine
-METHOD committed
-AT ENTRY
-BIND engine : CoordinatorEngine = $0,
- identifier:String = engine.getId()
-IF debug("received committed for participant " + identifier)
- AND
- (waiting(identifier)
- AND
- signalWake(identifier))
-DO debug("signalled coordinator waiting on " + identifier)
-ENDRULE
-
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/docs/ProgrammersGuide.pdf
===================================================================
(Binary files differ)
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample)
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/build.xml
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/build.xml 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/build.xml 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,86 +0,0 @@
-<!--
- JBoss, Home of Professional Open Source
- Copyright 2009, Red Hat Middleware LLC, and individual contributors
- as indicated by the @author tags.
- See the copyright.txt in the distribution for a full listing
- of individual contributors.
- This copyrighted material is made available to anyone wishing to use,
- modify, copy, or redistribute it subject to the terms and conditions
- of the GNU General Public License, v. 2.0.
- This program is distributed in the hope that it will be useful, but WITHOUT A
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License,
- v. 2.0 along with this distribution; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-
- (C) 2009
- @author JBoss Inc.
--->
-
-<project name="byteman-sample" default="install" basedir=".">
-
- <!-- n.b. we assume the byteman jar has been installed in the parent tree -->
- <property name="byteman.jar" value="byteman.jar"/>
- <property name="byteman.sample.jar" value="byteman-sample.jar"/>
-
- <!-- paths for local build -->
- <property name="src.dir" value="src"/>
- <property name="scripts.dir" value="scripts"/>
- <property name="build.dir" value="build"/>
- <property name="build.classes.dir" value="${build.dir}/classes"/>
- <property name="build.lib.dir" value="${build.dir}/lib"/>
-
- <!-- paths for installation into parent install tree -->
- <property name="parent.install.dir" value="../install"/>
- <property name="install.sample.dir" value="${parent.install.dir}/sample"/>
- <property name="install.sample.lib.dir" value="${install.sample.dir}/lib"/>
- <property name="install.sample.scripts.dir" value="${install.sample.dir}/scripts"/>
-
- <!-- enable debugging of compiled code including refs to local vars -->
- <property name="javac.debug" value="on"/>
-
- <target name="init">
- <delete dir="${build.dir}"/>
- <mkdir dir="${build.dir}"/>
- <mkdir dir="${build.classes.dir}"/>
- <mkdir dir="${build.lib.dir}"/>
- </target>
-
- <target name="compile" depends="init">
- <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="${javac.debug}">
- <classpath>
- <pathelement location="${parent.install.dir}/lib/${byteman.jar}"/>
- </classpath>
- </javac>
- </target>
-
- <target name="jar" depends="compile">
- <jar jarfile="${build.lib.dir}/${byteman.sample.jar}">
- <fileset dir="${build.classes.dir}" includes="**/*"/>
- </jar>
- </target>
-
- <target name="init-install">
- <delete dir="${install.sample.dir}" />
- <mkdir dir="${install.sample.dir}" />
- <mkdir dir="${install.sample.lib.dir}" />
- <mkdir dir="${install.sample.scripts.dir}" />
- </target>
-
- <target name="install" depends="jar, init-install">
- <copy todir="${install.sample.lib.dir}" file="${build.lib.dir}/${byteman.sample.jar}"/>
- <copy todir="${install.sample.scripts.dir}">
- <fileset dir="${scripts.dir}" includes="*.txt *.bms"/>
- </copy>
- </target>
-
- <target name="clean">
- <delete dir="${build.dir}"/>
- </target>
-
- <target name="spotless">
- <delete dir="${install.sample.dir}"/>
- </target>
-</project>
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/build.xml (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/build.xml)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/build.xml (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/build.xml 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,86 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags.
+ See the copyright.txt in the distribution for a full listing
+ of individual contributors.
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the GNU General Public License, v. 2.0.
+ This program is distributed in the hope that it will be useful, but WITHOUT A
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License,
+ v. 2.0 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ (C) 2009
+ @author JBoss Inc.
+-->
+
+<project name="byteman-sample" default="install" basedir=".">
+
+ <!-- n.b. we assume the byteman jar has been installed in the parent tree -->
+ <property name="byteman.jar" value="byteman.jar"/>
+ <property name="byteman.sample.jar" value="byteman-sample.jar"/>
+
+ <!-- paths for local build -->
+ <property name="src.dir" value="src"/>
+ <property name="scripts.dir" value="scripts"/>
+ <property name="build.dir" value="build"/>
+ <property name="build.classes.dir" value="${build.dir}/classes"/>
+ <property name="build.lib.dir" value="${build.dir}/lib"/>
+
+ <!-- paths for installation into parent install tree -->
+ <property name="parent.install.dir" value="../install"/>
+ <property name="install.sample.dir" value="${parent.install.dir}/sample"/>
+ <property name="install.sample.lib.dir" value="${install.sample.dir}/lib"/>
+ <property name="install.sample.scripts.dir" value="${install.sample.dir}/scripts"/>
+
+ <!-- enable debugging of compiled code including refs to local vars -->
+ <property name="javac.debug" value="on"/>
+
+ <target name="init">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.lib.dir}"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="${javac.debug}">
+ <classpath>
+ <pathelement location="${parent.install.dir}/lib/${byteman.jar}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="jar" depends="compile">
+ <jar jarfile="${build.lib.dir}/${byteman.sample.jar}">
+ <fileset dir="${build.classes.dir}" includes="**/*"/>
+ </jar>
+ </target>
+
+ <target name="init-install">
+ <delete dir="${install.sample.dir}" />
+ <mkdir dir="${install.sample.dir}" />
+ <mkdir dir="${install.sample.lib.dir}" />
+ <mkdir dir="${install.sample.scripts.dir}" />
+ </target>
+
+ <target name="install" depends="jar, init-install">
+ <copy todir="${install.sample.lib.dir}" file="${build.lib.dir}/${byteman.sample.jar}"/>
+ <copy todir="${install.sample.scripts.dir}">
+ <fileset dir="${scripts.dir}" includes="*.txt *.bms"/>
+ </copy>
+ </target>
+
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ </target>
+
+ <target name="spotless">
+ <delete dir="${install.sample.dir}"/>
+ </target>
+</project>
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts)
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ClassLoadMonitor.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/ClassLoadMonitor.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ClassLoadMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,55 +0,0 @@
-########################################################################
-# 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
-#
-# ClassLoadMonitor
-#
-# A byteman script which prints a stacktrace whenever ClassLoader.defineClass
-# is called.
-#
-# to use ths script to trace execution of java program org.my.App execute
-#
-# -- set the directory in which byteman has been installed
-# BYTEMAN_HOME= ...
-#
-# -- identify the samples jar to the boot path
-# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
-#
-# -- identify this script
-# SCRIPT={BYTEMAN_HOME}/sample/scripts/ClassLoadMonitor.txt
-#
-# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
-#
-
-########################################################################
-#
-# Rule to trace class load
-#
-
-RULE ClassLoadMonitor trace create
-CLASS java.lang.ClassLoader
-METHOD defineClass(String, byte[], int, int, ProtectionDomain)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** Called defineClass(" + $1 + ") in thread " + Thread.currentThread().getName() + "\n")
-ENDRULE
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ClassLoadMonitor.txt (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/ClassLoadMonitor.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ClassLoadMonitor.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ClassLoadMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,55 @@
+########################################################################
+# 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
+#
+# ClassLoadMonitor
+#
+# A byteman script which prints a stacktrace whenever ClassLoader.defineClass
+# is called.
+#
+# to use ths script to trace execution of java program org.my.App execute
+#
+# -- set the directory in which byteman has been installed
+# BYTEMAN_HOME= ...
+#
+# -- identify the samples jar to the boot path
+# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
+#
+# -- identify this script
+# SCRIPT={BYTEMAN_HOME}/sample/scripts/ClassLoadMonitor.txt
+#
+# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
+#
+
+########################################################################
+#
+# Rule to trace class load
+#
+
+RULE ClassLoadMonitor trace create
+CLASS java.lang.ClassLoader
+METHOD defineClass(String, byte[], int, int, ProtectionDomain)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** Called defineClass(" + $1 + ") in thread " + Thread.currentThread().getName() + "\n")
+ENDRULE
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FileMonitor.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/FileMonitor.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FileMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,111 +0,0 @@
-########################################################################
-# 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
-#
-# FileMonitor
-#
-# A byteman script which prints a stack trace whenever a file input or
-# output stream is created from a File instance or subsequently closed.
-#
-# to use ths script to trace execution of java program org.my.App execute
-#
-# -- set the directory in which byteman has been installed
-# BYTEMAN_HOME= ...
-#
-# -- identify the samples jar to the boot path
-# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
-#
-# -- identify this script
-# SCRIPT={BYTEMAN_HOME}/sample/scripts/FileMonitor.txt
-#
-# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
-#
-
-########################################################################
-#
-# Rule to trace create of file input stream from File
-#
-
-RULE FileMonitor trace FileInputStream create from File
-CLASS java.io.FileInputStream
-METHOD <init>(java.io.File)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT RETURN
-IF TRUE
-DO traceStack("*** Opened " + $1.getPath() + " for read in thread " + Thread.currentThread().getName() + "\n")
-ENDRULE
-
-########################################################################
-#
-# Rule to trace close of file input stream close
-#
-
-RULE FileMonitor trace FileInputStream close
-CLASS java.io.FileInputStream
-METHOD close
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT RETURN
-IF TRUE
-DO traceStack("*** Closed " + $0 + " in thread " + Thread.currentThread().getName() + "\n")
-ENDRULE
-
-########################################################################
-#
-# Rule to trace create of file output stream from File
-#
-
-RULE FileMonitor trace FileOutputStream create from File
-CLASS java.io.FileOutputStream
-METHOD <init>(java.io.File)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT RETURN
-IF TRUE
-DO traceStack("*** Opened " + $1.getPath() + " for write in thread " + Thread.currentThread().getName() + "\n")
-ENDRULE
-
-########################################################################
-#
-# Rule to trace create of file output stream from String
-#
-
-RULE FileMonitor trace FileOutputStream create from String
-CLASS java.io.FileOutputStream
-METHOD <init>(String, boolean)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT RETURN
-IF TRUE
-DO traceStack("*** Opened " + $1 + " for " + ($2 ? "write" : "append") +" in thread " + Thread.currentThread().getName() + "\n")
-ENDRULE
-
-########################################################################
-#
-# Rule to trace close of file output
-#
-
-RULE FileMonitor trace FileOutputStream close
-CLASS java.io.FileOutputStream
-METHOD <init>(String, boolean)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT RETURN
-IF TRUE
-DO traceStack("*** Closed " + $0 + " in thread " + Thread.currentThread().getName() + "\n")
-ENDRULE
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FileMonitor.txt (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/FileMonitor.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FileMonitor.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FileMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,111 @@
+########################################################################
+# 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
+#
+# FileMonitor
+#
+# A byteman script which prints a stack trace whenever a file input or
+# output stream is created from a File instance or subsequently closed.
+#
+# to use ths script to trace execution of java program org.my.App execute
+#
+# -- set the directory in which byteman has been installed
+# BYTEMAN_HOME= ...
+#
+# -- identify the samples jar to the boot path
+# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
+#
+# -- identify this script
+# SCRIPT={BYTEMAN_HOME}/sample/scripts/FileMonitor.txt
+#
+# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
+#
+
+########################################################################
+#
+# Rule to trace create of file input stream from File
+#
+
+RULE FileMonitor trace FileInputStream create from File
+CLASS java.io.FileInputStream
+METHOD <init>(java.io.File)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT RETURN
+IF TRUE
+DO traceStack("*** Opened " + $1.getPath() + " for read in thread " + Thread.currentThread().getName() + "\n")
+ENDRULE
+
+########################################################################
+#
+# Rule to trace close of file input stream close
+#
+
+RULE FileMonitor trace FileInputStream close
+CLASS java.io.FileInputStream
+METHOD close
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT RETURN
+IF TRUE
+DO traceStack("*** Closed " + $0 + " in thread " + Thread.currentThread().getName() + "\n")
+ENDRULE
+
+########################################################################
+#
+# Rule to trace create of file output stream from File
+#
+
+RULE FileMonitor trace FileOutputStream create from File
+CLASS java.io.FileOutputStream
+METHOD <init>(java.io.File)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT RETURN
+IF TRUE
+DO traceStack("*** Opened " + $1.getPath() + " for write in thread " + Thread.currentThread().getName() + "\n")
+ENDRULE
+
+########################################################################
+#
+# Rule to trace create of file output stream from String
+#
+
+RULE FileMonitor trace FileOutputStream create from String
+CLASS java.io.FileOutputStream
+METHOD <init>(String, boolean)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT RETURN
+IF TRUE
+DO traceStack("*** Opened " + $1 + " for " + ($2 ? "write" : "append") +" in thread " + Thread.currentThread().getName() + "\n")
+ENDRULE
+
+########################################################################
+#
+# Rule to trace close of file output
+#
+
+RULE FileMonitor trace FileOutputStream close
+CLASS java.io.FileOutputStream
+METHOD <init>(String, boolean)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT RETURN
+IF TRUE
+DO traceStack("*** Closed " + $0 + " in thread " + Thread.currentThread().getName() + "\n")
+ENDRULE
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FinalizeMonitor.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/FinalizeMonitor.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FinalizeMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,53 +0,0 @@
-########################################################################
-# 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
-#
-# FinalizeMonitor
-#
-# A byteman script which traces calls to Object.finalize().
-#
-# to use ths script to trace execution of java program org.my.App execute
-#
-# -- set the directory in which byteman has been installed
-# BYTEMAN_HOME= ...
-#
-# -- identify the samples jar to the boot path
-# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
-#
-# -- identify this script
-# SCRIPT={BYTEMAN_HOME}/sample/scripts/FinalizeMonitor.txt
-#
-# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
-#
-
-########################################################################
-#
-# Rule to trace calls to Object.finalize()
-#
-
-RULE FinalizeMonitor trace finalize
-CLASS java.lang.Object
-METHOD finalize
-AT RETURN
-IF TRUE
-DO traceln("finalizing " + $0)
-ENDRULE
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FinalizeMonitor.txt (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/FinalizeMonitor.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FinalizeMonitor.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/FinalizeMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,53 @@
+########################################################################
+# 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
+#
+# FinalizeMonitor
+#
+# A byteman script which traces calls to Object.finalize().
+#
+# to use ths script to trace execution of java program org.my.App execute
+#
+# -- set the directory in which byteman has been installed
+# BYTEMAN_HOME= ...
+#
+# -- identify the samples jar to the boot path
+# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
+#
+# -- identify this script
+# SCRIPT={BYTEMAN_HOME}/sample/scripts/FinalizeMonitor.txt
+#
+# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
+#
+
+########################################################################
+#
+# Rule to trace calls to Object.finalize()
+#
+
+RULE FinalizeMonitor trace finalize
+CLASS java.lang.Object
+METHOD finalize
+AT RETURN
+IF TRUE
+DO traceln("finalizing " + $0)
+ENDRULE
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/SocketMonitor.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/SocketMonitor.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/SocketMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,276 +0,0 @@
-########################################################################
-# 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
-#
-# SocketMonitor
-#
-# A byteman script which traces thread creation, start, run and exit
-#
-# to use ths script to trace execution of java program org.my.App execute
-#
-# -- set the directory in which byteman has been installed
-# BYTEMAN_HOME= ...
-#
-# -- identify the samples jar to the boot path
-# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
-#
-# -- identify this script
-# SCRIPT={BYTEMAN_HOME}/sample/scripts/SocketMonitor.txt
-#
-# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
-#
-
-########################################################################
-#
-# Rule to trace ServerSocket creation
-#
-
-RULE ServerSocket trace create
-CLASS java.net.ServerSocket
-METHOD <init>(int, int, InetAddress)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** server create " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace ServerSocket creation failed with invalid port
-#
-
-RULE ServerSocket trace create failed with invalid port
-CLASS java.net.ServerSocket
-METHOD <init>(int, int, InetAddress)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT THROW 1
-IF TRUE
-DO traceStack("*** server create failed with invalid port " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace ServerSocket creation failed with security exception
-#
-
-RULE ServerSocket trace create failed with security exception
-CLASS java.net.ServerSocket
-METHOD <init>(int, int, InetAddress)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT THROW 2
-IF TRUE
-DO traceStack("*** server create failed with security exception " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace ServerSocket creation failed with IOException
-#
-
-RULE ServerSocket trace create failed with IOException
-CLASS java.net.ServerSocket
-METHOD <init>(int, int, InetAddress)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT THROW 3
-IF TRUE
-DO traceStack("*** server create failed with IOException " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace ServerSocket bind
-#
-
-RULE ServerSocket trace bind
-CLASS java.net.ServerSocket
-METHOD bind(SocketAddress, int)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** server bind " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace ServerSocket accept
-#
-
-RULE ServerSocket trace accept
-CLASS java.net.ServerSocket
-METHOD accept()
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** server accept " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace ServerSocket close
-#
-# the AT CALL close location means we do not trace calls to already closed sockets
-#
-
-RULE ServerSocket trace close
-CLASS java.net.ServerSocket
-METHOD close
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT CALL close
-IF TRUE
-DO traceStack("*** server close " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket create
-#
-
-RULE Socket trace create
-CLASS java.net.Socket
-METHOD <init>(SocketAddress, SocketAddress, boolean)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** create " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket create failed with invalid address
-#
-
-RULE Socket trace create failed with invalid address
-CLASS java.net.Socket
-METHOD <init>(SocketAddress, SocketAddress, boolean)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT THROW 1
-IF TRUE
-DO traceStack("*** create failed with invalid address exception " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket create failed with IOException
-#
-
-RULE Socket trace create failed with IOException
-CLASS java.net.Socket
-METHOD <init>(SocketAddress, SocketAddress, boolean)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT THROW 2
-IF TRUE
-DO traceStack("*** create failed with IOException " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket bind
-#
-
-RULE Socket trace bind
-CLASS java.net.Socket
-METHOD bind(SocketAddress)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** bind " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket connect
-#
-
-RULE Socket trace connect
-CLASS java.net.Socket
-METHOD connect(SocketAddress, int)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** connect " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket close
-#
-# the AT CALL close location means we do not trace calls to already closed sockets
-#
-
-RULE Socket trace close
-CLASS java.net.Socket
-METHOD close()
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT CALL close
-IF TRUE
-DO traceStack("*** close " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# The Sun code overrides the standard socket methdos without calling
-# super() so we need to add special case rules for the overriding
-# methods.
-
-########################################################################
-#
-# Rule to trace socket bind for Sun's socket impl
-#
-
-RULE Socket trace bind for Sun's socket impl
-CLASS sun.nio.ch.ServerSocketChannelImpl
-METHOD bind(SocketAddress)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** bind for Sun's socket impl " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket connect for Sun's socket impl
-#
-
-RULE Socket trace connect for Sun's socket impl
-CLASS sun.nio.ch.ServerSocketChannelImpl
-METHOD connect(SocketAddress, int)
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT EXIT
-IF TRUE
-DO traceStack("*** connect for Sun's socket impl " + $0, 15)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace socket close for Sun's socket impl
-#
-# the AT CALL close location means we do not trace calls to already closed sockets
-#
-
-RULE Socket trace close for Sun's socket impl
-CLASS sun.nio.ch.ServerSocketChannelImpl
-METHOD close()
-HELPER org.jboss.byteman.sample.helper.StackTraceHelper
-AT CALL close
-IF TRUE
-DO traceStack("*** close for Sun's socket impl " + $0, 15)
-ENDRULE
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/SocketMonitor.txt (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/SocketMonitor.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/SocketMonitor.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/SocketMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,276 @@
+########################################################################
+# 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
+#
+# SocketMonitor
+#
+# A byteman script which traces thread creation, start, run and exit
+#
+# to use ths script to trace execution of java program org.my.App execute
+#
+# -- set the directory in which byteman has been installed
+# BYTEMAN_HOME= ...
+#
+# -- identify the samples jar to the boot path
+# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
+#
+# -- identify this script
+# SCRIPT={BYTEMAN_HOME}/sample/scripts/SocketMonitor.txt
+#
+# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
+#
+
+########################################################################
+#
+# Rule to trace ServerSocket creation
+#
+
+RULE ServerSocket trace create
+CLASS java.net.ServerSocket
+METHOD <init>(int, int, InetAddress)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** server create " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace ServerSocket creation failed with invalid port
+#
+
+RULE ServerSocket trace create failed with invalid port
+CLASS java.net.ServerSocket
+METHOD <init>(int, int, InetAddress)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT THROW 1
+IF TRUE
+DO traceStack("*** server create failed with invalid port " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace ServerSocket creation failed with security exception
+#
+
+RULE ServerSocket trace create failed with security exception
+CLASS java.net.ServerSocket
+METHOD <init>(int, int, InetAddress)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT THROW 2
+IF TRUE
+DO traceStack("*** server create failed with security exception " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace ServerSocket creation failed with IOException
+#
+
+RULE ServerSocket trace create failed with IOException
+CLASS java.net.ServerSocket
+METHOD <init>(int, int, InetAddress)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT THROW 3
+IF TRUE
+DO traceStack("*** server create failed with IOException " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace ServerSocket bind
+#
+
+RULE ServerSocket trace bind
+CLASS java.net.ServerSocket
+METHOD bind(SocketAddress, int)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** server bind " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace ServerSocket accept
+#
+
+RULE ServerSocket trace accept
+CLASS java.net.ServerSocket
+METHOD accept()
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** server accept " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace ServerSocket close
+#
+# the AT CALL close location means we do not trace calls to already closed sockets
+#
+
+RULE ServerSocket trace close
+CLASS java.net.ServerSocket
+METHOD close
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT CALL close
+IF TRUE
+DO traceStack("*** server close " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket create
+#
+
+RULE Socket trace create
+CLASS java.net.Socket
+METHOD <init>(SocketAddress, SocketAddress, boolean)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** create " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket create failed with invalid address
+#
+
+RULE Socket trace create failed with invalid address
+CLASS java.net.Socket
+METHOD <init>(SocketAddress, SocketAddress, boolean)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT THROW 1
+IF TRUE
+DO traceStack("*** create failed with invalid address exception " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket create failed with IOException
+#
+
+RULE Socket trace create failed with IOException
+CLASS java.net.Socket
+METHOD <init>(SocketAddress, SocketAddress, boolean)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT THROW 2
+IF TRUE
+DO traceStack("*** create failed with IOException " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket bind
+#
+
+RULE Socket trace bind
+CLASS java.net.Socket
+METHOD bind(SocketAddress)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** bind " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket connect
+#
+
+RULE Socket trace connect
+CLASS java.net.Socket
+METHOD connect(SocketAddress, int)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** connect " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket close
+#
+# the AT CALL close location means we do not trace calls to already closed sockets
+#
+
+RULE Socket trace close
+CLASS java.net.Socket
+METHOD close()
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT CALL close
+IF TRUE
+DO traceStack("*** close " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# The Sun code overrides the standard socket methdos without calling
+# super() so we need to add special case rules for the overriding
+# methods.
+
+########################################################################
+#
+# Rule to trace socket bind for Sun's socket impl
+#
+
+RULE Socket trace bind for Sun's socket impl
+CLASS sun.nio.ch.ServerSocketChannelImpl
+METHOD bind(SocketAddress)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** bind for Sun's socket impl " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket connect for Sun's socket impl
+#
+
+RULE Socket trace connect for Sun's socket impl
+CLASS sun.nio.ch.ServerSocketChannelImpl
+METHOD connect(SocketAddress, int)
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT EXIT
+IF TRUE
+DO traceStack("*** connect for Sun's socket impl " + $0, 15)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace socket close for Sun's socket impl
+#
+# the AT CALL close location means we do not trace calls to already closed sockets
+#
+
+RULE Socket trace close for Sun's socket impl
+CLASS sun.nio.ch.ServerSocketChannelImpl
+METHOD close()
+HELPER org.jboss.byteman.sample.helper.StackTraceHelper
+AT CALL close
+IF TRUE
+DO traceStack("*** close for Sun's socket impl " + $0, 15)
+ENDRULE
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ThreadMonitor.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/ThreadMonitor.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ThreadMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,82 +0,0 @@
-########################################################################
-# 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
-#
-# ThreadMonitor
-#
-# A byteman script which traces thread creation, start, run and exit
-#
-# to use ths script to trace execution of java program org.my.App execute
-#
-# -- set the directory in which byteman has been installed
-# BYTEMAN_HOME= ...
-#
-# -- identify the samples jar to the boot path
-# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
-#
-# -- identify this script
-# SCRIPT={BYTEMAN_HOME}/sample/scripts/ThreadMonitor.txt
-#
-# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
-#
-
-########################################################################
-#
-# Rule to trace thread creation
-#
-
-RULE ThreadMonitor trace create
-CLASS java.lang.Thread
-METHOD <init>
-HELPER org.jboss.byteman.sample.helper.ThreadMonitorHelper
-AT EXIT
-IF TRUE
-DO traceCreate($0)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace thread start
-#
-
-RULE ThreadMonitor trace start
-CLASS java.lang.Thread
-METHOD start
-HELPER org.jboss.byteman.sample.helper.ThreadMonitorHelper
-AT EXIT
-IF TRUE
-DO traceStart($0)
-ENDRULE
-
-########################################################################
-#
-# Rule to trace thread exit
-#
-
-RULE ThreadMonitor trace exit
-CLASS java.lang.Thread
-METHOD exit
-HELPER org.jboss.byteman.sample.helper.ThreadMonitorHelper
-AT ENTRY
-IF TRUE
-DO traceExit($0)
-ENDRULE
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ThreadMonitor.txt (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/scripts/ThreadMonitor.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ThreadMonitor.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/scripts/ThreadMonitor.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,82 @@
+########################################################################
+# 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
+#
+# ThreadMonitor
+#
+# A byteman script which traces thread creation, start, run and exit
+#
+# to use ths script to trace execution of java program org.my.App execute
+#
+# -- set the directory in which byteman has been installed
+# BYTEMAN_HOME= ...
+#
+# -- identify the samples jar to the boot path
+# SAMPLE_JAR=${BYTEMAN_HOME}/sample/lib/byteman-sample.jar
+#
+# -- identify this script
+# SCRIPT={BYTEMAN_HOME}/sample/scripts/ThreadMonitor.txt
+#
+# ${BYTEMAN_HOME}/bin/bmjava.sh -l $SCRIPT -b $SAMPLE_JAR org.my.App
+#
+
+########################################################################
+#
+# Rule to trace thread creation
+#
+
+RULE ThreadMonitor trace create
+CLASS java.lang.Thread
+METHOD <init>
+HELPER org.jboss.byteman.sample.helper.ThreadMonitorHelper
+AT EXIT
+IF TRUE
+DO traceCreate($0)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace thread start
+#
+
+RULE ThreadMonitor trace start
+CLASS java.lang.Thread
+METHOD start
+HELPER org.jboss.byteman.sample.helper.ThreadMonitorHelper
+AT EXIT
+IF TRUE
+DO traceStart($0)
+ENDRULE
+
+########################################################################
+#
+# Rule to trace thread exit
+#
+
+RULE ThreadMonitor trace exit
+CLASS java.lang.Thread
+METHOD exit
+HELPER org.jboss.byteman.sample.helper.ThreadMonitorHelper
+AT ENTRY
+IF TRUE
+DO traceExit($0)
+ENDRULE
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src)
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org)
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss)
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss/byteman)
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss/byteman/sample)
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss/byteman/sample/helper)
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,416 +0,0 @@
-package org.jboss.byteman.sample.helper;
-
-import org.jboss.byteman.rule.helper.Helper;
-import org.jboss.byteman.rule.Rule;
-import org.jboss.byteman.rule.exception.ExecuteException;
-
-import java.util.Map;
-import java.lang.management.ThreadMXBean;
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadInfo;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * Helper class providing support for stack scanning and tracing
- */
-public class StackTraceHelper extends Helper
-{
- private static String RULE_CLASS_NAME = Rule.class.getCanonicalName();
- private static String RULE_EXECUTE_METHOD_NAME = "execute";
-
- protected StackTraceElement[] stack;
-
- protected StackTraceHelper(Rule rule) {
- super(rule);
- stack = Thread.currentThread().getStackTrace();
- }
-
- /**
- * return the index of the frame for the trigger method below which the rule system created
- * this helper or -1 if it cannot be found
- * @return the index of the frame for the trigger method or -1 if it cannot be found
- */
- protected int triggerIndex()
- {
- return triggerIndex(stack);
- }
-
- /**
- * return the index of the frame in stack for the trigger method below which the rule system
- * was entered or -1 if it cannot be found
- * @return the index of the frame for the trigger method or -1 if it cannot be found
- */
- protected int triggerIndex(StackTraceElement[] stack)
- {
- int l= stack.length;
- int i;
- // find the trigger method frame above the rule engine entry point
- // we should see two calls to rule.execute()
- for (i = 0; i < l; i++) {
- if (RULE_CLASS_NAME.equals(stack[i].getClassName()) &&
- RULE_EXECUTE_METHOD_NAME.equals(stack[i].getMethodName())) {
- break;
- }
- }
-
- if (i >= l - 1 ||
- !RULE_CLASS_NAME.equals(stack[i].getClassName()) ||
- !RULE_EXECUTE_METHOD_NAME.equals(stack[i].getMethodName())) {
- // illegal usage
- new ExecuteException("StacktraceHelper.traceStack : can only be called below Rule.execute()").printStackTrace();
- return -1;
- }
-
- return i + 2;
- }
-
- /**
- * return the index of the first frame at or below index start which matches pattern
- * @param pattern a pattern to be matched against the concatenated stack classname and methodname using
- * String.matches()
- * @param start the index of the first frame which should be tested for a match. this must be greater than
- * or equal to the trigger index.
- * @param limit the index of the first frame which should not be tested for a match. this must be less than
- * or equal to the stack length
- * @return the index of the matching frame between start and limit - 1 or -1 if it no match found
- */
- protected int matchIndex(String pattern, int start, int limit)
- {
- int l= stack.length;
- int i = start;
- // find the trigger method frame above the rule engine entry point
- // we should see two calls to rule.execute()
- for (i = 0; i < limit; i++) {
- String fullName = stack[i].getClassName() + "." + stack[i].getMethodName();
- if (fullName.matches(pattern)) {
- return i;
- }
- }
-
- return -1;
- }
-
- /**
- * print the details of the current stack frame at index idx followed by a newline to buffer by calling
- * printlnFrame(buffer, stack[idx])
- * @param buffer
- * @param idx
- */
- protected void printlnFrame(StringBuffer buffer, int idx)
- {
- printlnFrame(buffer, stack[idx]);
- }
-
- /**
- * print the details of stack frame at index idx to buffer
- * print the details of stack frame to buffer
- * @param buffer
- * @param idx
- */
- protected void printFrame(StringBuffer buffer, int idx)
- {
- printFrame(buffer, stack[idx]);
- }
-
- /**
- * print the details of stack frame followed by a newline to buffer by calling
- * printlnFrame(buffer, frame) then buffer.append('\n')
- * @param buffer
- * @param frame
- */
- protected void printlnFrame(StringBuffer buffer, StackTraceElement frame)
- {
- printFrame(buffer, frame);
- buffer.append('\n');
- }
-
- /**
- * print the details of stack frame to buffer
- * @param buffer
- * @param frame
- */
- protected void printFrame(StringBuffer buffer, StackTraceElement frame)
- {
- buffer.append(frame.getClassName());
- buffer.append(".");
- buffer.append(frame.getMethodName());
- buffer.append(" at ");
- buffer.append(frame.getFileName());
- buffer.append(":");
- buffer.append(frame.getLineNumber());
- }
-
- /**
- * print a stack trace to System.out by calling traceStack(null)
- */
- public void traceStack()
- {
- traceStack(null);
- }
-
- /**
- * print a stack trace to System.out by calling traceStack(prefix, "out")
- */
- public void traceStack(String prefix)
- {
- traceStack(prefix, "out");
- }
-
- /**
- * print a stack trace to System.out by calling traceStack(prefix, key, 0)
- */
- public void traceStack(String prefix, Object key)
- {
- traceStack(prefix, key, 0);
- }
-
- /**
- * print a stack trace to System.out by calling traceStack(null, maxFrames)
- */
- public void traceStack(int maxFrames)
- {
- traceStack(null, maxFrames);
- }
-
- /**
- * print a stack trace to System.out by calling traceStack(prefix, "out", maxFrames)
- */
- public void traceStack(String prefix, int maxFrames)
- {
- traceStack(prefix, "out", maxFrames);
- }
-
- /**
- * print a stack trace to the trace stream identified by key
- *
- * @param prefix a String to be printed once before printing each line of stack trace. if supplied as null
- * then the prefix "Stack trace for thread " + Thread.currentThread().getName() + "\n" is used
- * @param key an object identifying the trace stream to which output should be generated
- * @param maxFrames the maximum number of frames to print or 0 if no limit should apply
- */
- public void traceStack(String prefix, Object key, int maxFrames)
- {
- StringBuffer buffer = new StringBuffer();
- int l = stack.length;
- int i = triggerIndex();
-
- if (i < 0) {
- return;
- }
-
- if (prefix != null) {
- buffer.append(prefix);
- } else {
- buffer.append("Stack trace for thread ");
- buffer.append(Thread.currentThread().getName());
- buffer.append('\n');
- }
- boolean dotdotdot = false;
-
- if (maxFrames > 0 && (i + maxFrames) < l) {
- l = i + maxFrames;
- dotdotdot = true;
- }
-
- for (; i < l; i++) {
- printlnFrame(buffer, i);
- }
- if (dotdotdot) {
- buffer.append(" . . .\n");
- }
-
- trace(key, buffer.toString());
- }
-
- /**
- * print all stack frames which match pattern to System.out by calling traceStackMatching(pattern, null)
- */
-
- public void traceStackMatching(String pattern)
- {
- traceStackMatching(pattern, null);
- }
-
- /**
- * print all stack frames which match pattern to System.out preceded by prefix by calling
- * traceStackMatching(pattern, null, "out")
- */
-
- public void traceStackMatching(String pattern, String prefix)
- {
- traceStackMatching(pattern, null, "out");
- }
-
- /**
- * print all stack frames which match pattern to the trace stream identified by key preceded by prefix.
- *
- * @param pattern a pattern which will be matched against the concatenated classname and
- * method name of the stack frame by calling String.matches()
- * @param prefix a String to be printed once before printing each line of stack trace. if supplied as null
- * then the prefix "Stack trace for thread " + Thread.currentThread().getName() + " matching " + pattern + "\n" is used
- * @param key an object identifying the trace stream to which output should be generated
- */
-
- public void traceStackMatching(String pattern, String prefix, Object key)
- {
- StringBuffer buffer = new StringBuffer();
- int l = stack.length;
- int i = triggerIndex();
-
- if (i < 0) {
- return;
- }
-
- if (prefix != null) {
- buffer.append(prefix);
- } else {
- buffer.append("Stack trace for thread ");
- buffer.append(Thread.currentThread().getName());
- buffer.append(" matching ");
- buffer.append(pattern);
- buffer.append('\n');
- }
- for (; i < l; i++) {
- String fullName = stack[i].getClassName() + "." + stack[i].getMethodName();
- if (fullName.matches(pattern)) {
- printlnFrame(buffer, i);
- }
- }
-
- trace(key, buffer.toString());
- }
-
- /**
- * print all stack frames between the frames which match start and end to System.out by calling
- * traceStackMatching(from, to, null)
- */
-
- public void traceStackBetween(String from, String to)
- {
- traceStackBetween(from, to, null);
- }
-
- /**
- * print all stack frames between the frames which match start and end to System.out preceded by prefix
- * by calling traceStackMatching(from, to, null, "out")
- */
-
- public void traceStackBetween(String from, String to, String prefix)
- {
- traceStackBetween(from, to, null, "out");
- }
-
- /**
- * print all stack frames between the frames which match start and end to the trace stream identified by key
- * preceded by prefix.
- *
- * @param from a pattern which identifies the first frame which should be printed. from will be matched against
- * the concatenated classname and method name of each successive stack frame by calling String.matches().
- * If null is supplied then the trigger frame will be used as the first frame to print. If a non-null value
- * is supplied and no match is foudn then no farmes will be printed.
- * @param to a pattern which identifies the last frame which should be printed. to will be matched against
- * the concatenated classname and method name of each successive stack frame by calling String.matches().
- * If null is supplied or no match is found then the bottom frame will be used as the last frame to print.
- * @param prefix a String to be printed once before printing each line of stack trace. if supplied as null
- * then the prefix "Stack trace (restricted) for " + Thread.currentThread().getName() + "\n" is used
- * @param key an object identifying the trace stream to which output should be generated
- */
-
- public void traceStackBetween(String from, String to, String prefix, Object key)
- {
- StringBuffer buffer = new StringBuffer();
- int l = stack.length;
- int i = triggerIndex();
- if (i < 0) {
- return;
- }
-
- int first;
- if (from != null) {
- first = matchIndex(from, i, l);
- if (first < 0) {
- return;
- }
- } else {
- first = i;
- }
-
- int last;
- if (to != null) {
- last = matchIndex(to, first + 1, l);
- if (last < 0) {
- last = l - 1;
- }
- } else {
- last = l - 1;
- }
-
- if (prefix != null) {
- buffer.append(prefix);
- } else {
- buffer.append("Stack trace (restricted) for ");
- buffer.append(Thread.currentThread().getName());
- buffer.append('\n');
- }
- for (i = first; i < last; i++) {
- printlnFrame(buffer, i);
- }
-
- trace(key, buffer.toString());
- }
-
- /**
- * print a stack trace of all threads in the system to System.out by calling traceStacks("out")
- */
- public void traceAllStacks()
- {
- traceAllStacks("out");
- }
-
- /**
- * print a stack trace of all threads in the system to the trace stream keyed by key
- */
- public void traceAllStacks(String key)
- {
- StringBuffer buffer = new StringBuffer();
- if (threadMXBean != null) {
- ThreadInfo[] threadInfo = threadMXBean.dumpAllThreads(threadMXBean.isObjectMonitorUsageSupported(), threadMXBean.isSynchronizerUsageSupported());
- for (int i = 0; i < threadInfo.length; i++) {
- buffer.append(threadInfo[i].toString());
- }
- } else {
- Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
- for (Map.Entry<Thread, StackTraceElement[]> entry : map.entrySet()) {
- Thread thread = entry.getKey();
- StackTraceElement[] stack = entry.getValue();
- int l = stack.length;
- int i = 0;
- buffer.append("Stack trace for thread ");
- buffer.append(Thread.currentThread().getName());
- buffer.append('\n');
- for (; i < l; i++) {
- printlnFrame(buffer, i);
- }
- buffer.append('\n');
- }
- }
- trace(key, buffer.toString());
- }
-
- private static ThreadMXBean threadMXBean = initThreadMXBean();
-
- private static ThreadMXBean initThreadMXBean() {
- try {
- return AccessController.doPrivileged(
- new PrivilegedExceptionAction<ThreadMXBean>() {
- public ThreadMXBean run() throws Exception {
- return ManagementFactory.getThreadMXBean();
- }
- });
- } catch (Exception exp) {
- throw new UnsupportedOperationException(exp);
- }
- }
-
-}
\ No newline at end of file
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/StackTraceHelper.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,416 @@
+package org.jboss.byteman.sample.helper;
+
+import org.jboss.byteman.rule.helper.Helper;
+import org.jboss.byteman.rule.Rule;
+import org.jboss.byteman.rule.exception.ExecuteException;
+
+import java.util.Map;
+import java.lang.management.ThreadMXBean;
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Helper class providing support for stack scanning and tracing
+ */
+public class StackTraceHelper extends Helper
+{
+ private static String RULE_CLASS_NAME = Rule.class.getCanonicalName();
+ private static String RULE_EXECUTE_METHOD_NAME = "execute";
+
+ protected StackTraceElement[] stack;
+
+ protected StackTraceHelper(Rule rule) {
+ super(rule);
+ stack = Thread.currentThread().getStackTrace();
+ }
+
+ /**
+ * return the index of the frame for the trigger method below which the rule system created
+ * this helper or -1 if it cannot be found
+ * @return the index of the frame for the trigger method or -1 if it cannot be found
+ */
+ protected int triggerIndex()
+ {
+ return triggerIndex(stack);
+ }
+
+ /**
+ * return the index of the frame in stack for the trigger method below which the rule system
+ * was entered or -1 if it cannot be found
+ * @return the index of the frame for the trigger method or -1 if it cannot be found
+ */
+ protected int triggerIndex(StackTraceElement[] stack)
+ {
+ int l= stack.length;
+ int i;
+ // find the trigger method frame above the rule engine entry point
+ // we should see two calls to rule.execute()
+ for (i = 0; i < l; i++) {
+ if (RULE_CLASS_NAME.equals(stack[i].getClassName()) &&
+ RULE_EXECUTE_METHOD_NAME.equals(stack[i].getMethodName())) {
+ break;
+ }
+ }
+
+ if (i >= l - 1 ||
+ !RULE_CLASS_NAME.equals(stack[i].getClassName()) ||
+ !RULE_EXECUTE_METHOD_NAME.equals(stack[i].getMethodName())) {
+ // illegal usage
+ new ExecuteException("StacktraceHelper.traceStack : can only be called below Rule.execute()").printStackTrace();
+ return -1;
+ }
+
+ return i + 2;
+ }
+
+ /**
+ * return the index of the first frame at or below index start which matches pattern
+ * @param pattern a pattern to be matched against the concatenated stack classname and methodname using
+ * String.matches()
+ * @param start the index of the first frame which should be tested for a match. this must be greater than
+ * or equal to the trigger index.
+ * @param limit the index of the first frame which should not be tested for a match. this must be less than
+ * or equal to the stack length
+ * @return the index of the matching frame between start and limit - 1 or -1 if it no match found
+ */
+ protected int matchIndex(String pattern, int start, int limit)
+ {
+ int l= stack.length;
+ int i = start;
+ // find the trigger method frame above the rule engine entry point
+ // we should see two calls to rule.execute()
+ for (i = 0; i < limit; i++) {
+ String fullName = stack[i].getClassName() + "." + stack[i].getMethodName();
+ if (fullName.matches(pattern)) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * print the details of the current stack frame at index idx followed by a newline to buffer by calling
+ * printlnFrame(buffer, stack[idx])
+ * @param buffer
+ * @param idx
+ */
+ protected void printlnFrame(StringBuffer buffer, int idx)
+ {
+ printlnFrame(buffer, stack[idx]);
+ }
+
+ /**
+ * print the details of stack frame at index idx to buffer
+ * print the details of stack frame to buffer
+ * @param buffer
+ * @param idx
+ */
+ protected void printFrame(StringBuffer buffer, int idx)
+ {
+ printFrame(buffer, stack[idx]);
+ }
+
+ /**
+ * print the details of stack frame followed by a newline to buffer by calling
+ * printlnFrame(buffer, frame) then buffer.append('\n')
+ * @param buffer
+ * @param frame
+ */
+ protected void printlnFrame(StringBuffer buffer, StackTraceElement frame)
+ {
+ printFrame(buffer, frame);
+ buffer.append('\n');
+ }
+
+ /**
+ * print the details of stack frame to buffer
+ * @param buffer
+ * @param frame
+ */
+ protected void printFrame(StringBuffer buffer, StackTraceElement frame)
+ {
+ buffer.append(frame.getClassName());
+ buffer.append(".");
+ buffer.append(frame.getMethodName());
+ buffer.append(" at ");
+ buffer.append(frame.getFileName());
+ buffer.append(":");
+ buffer.append(frame.getLineNumber());
+ }
+
+ /**
+ * print a stack trace to System.out by calling traceStack(null)
+ */
+ public void traceStack()
+ {
+ traceStack(null);
+ }
+
+ /**
+ * print a stack trace to System.out by calling traceStack(prefix, "out")
+ */
+ public void traceStack(String prefix)
+ {
+ traceStack(prefix, "out");
+ }
+
+ /**
+ * print a stack trace to System.out by calling traceStack(prefix, key, 0)
+ */
+ public void traceStack(String prefix, Object key)
+ {
+ traceStack(prefix, key, 0);
+ }
+
+ /**
+ * print a stack trace to System.out by calling traceStack(null, maxFrames)
+ */
+ public void traceStack(int maxFrames)
+ {
+ traceStack(null, maxFrames);
+ }
+
+ /**
+ * print a stack trace to System.out by calling traceStack(prefix, "out", maxFrames)
+ */
+ public void traceStack(String prefix, int maxFrames)
+ {
+ traceStack(prefix, "out", maxFrames);
+ }
+
+ /**
+ * print a stack trace to the trace stream identified by key
+ *
+ * @param prefix a String to be printed once before printing each line of stack trace. if supplied as null
+ * then the prefix "Stack trace for thread " + Thread.currentThread().getName() + "\n" is used
+ * @param key an object identifying the trace stream to which output should be generated
+ * @param maxFrames the maximum number of frames to print or 0 if no limit should apply
+ */
+ public void traceStack(String prefix, Object key, int maxFrames)
+ {
+ StringBuffer buffer = new StringBuffer();
+ int l = stack.length;
+ int i = triggerIndex();
+
+ if (i < 0) {
+ return;
+ }
+
+ if (prefix != null) {
+ buffer.append(prefix);
+ } else {
+ buffer.append("Stack trace for thread ");
+ buffer.append(Thread.currentThread().getName());
+ buffer.append('\n');
+ }
+ boolean dotdotdot = false;
+
+ if (maxFrames > 0 && (i + maxFrames) < l) {
+ l = i + maxFrames;
+ dotdotdot = true;
+ }
+
+ for (; i < l; i++) {
+ printlnFrame(buffer, i);
+ }
+ if (dotdotdot) {
+ buffer.append(" . . .\n");
+ }
+
+ trace(key, buffer.toString());
+ }
+
+ /**
+ * print all stack frames which match pattern to System.out by calling traceStackMatching(pattern, null)
+ */
+
+ public void traceStackMatching(String pattern)
+ {
+ traceStackMatching(pattern, null);
+ }
+
+ /**
+ * print all stack frames which match pattern to System.out preceded by prefix by calling
+ * traceStackMatching(pattern, null, "out")
+ */
+
+ public void traceStackMatching(String pattern, String prefix)
+ {
+ traceStackMatching(pattern, null, "out");
+ }
+
+ /**
+ * print all stack frames which match pattern to the trace stream identified by key preceded by prefix.
+ *
+ * @param pattern a pattern which will be matched against the concatenated classname and
+ * method name of the stack frame by calling String.matches()
+ * @param prefix a String to be printed once before printing each line of stack trace. if supplied as null
+ * then the prefix "Stack trace for thread " + Thread.currentThread().getName() + " matching " + pattern + "\n" is used
+ * @param key an object identifying the trace stream to which output should be generated
+ */
+
+ public void traceStackMatching(String pattern, String prefix, Object key)
+ {
+ StringBuffer buffer = new StringBuffer();
+ int l = stack.length;
+ int i = triggerIndex();
+
+ if (i < 0) {
+ return;
+ }
+
+ if (prefix != null) {
+ buffer.append(prefix);
+ } else {
+ buffer.append("Stack trace for thread ");
+ buffer.append(Thread.currentThread().getName());
+ buffer.append(" matching ");
+ buffer.append(pattern);
+ buffer.append('\n');
+ }
+ for (; i < l; i++) {
+ String fullName = stack[i].getClassName() + "." + stack[i].getMethodName();
+ if (fullName.matches(pattern)) {
+ printlnFrame(buffer, i);
+ }
+ }
+
+ trace(key, buffer.toString());
+ }
+
+ /**
+ * print all stack frames between the frames which match start and end to System.out by calling
+ * traceStackMatching(from, to, null)
+ */
+
+ public void traceStackBetween(String from, String to)
+ {
+ traceStackBetween(from, to, null);
+ }
+
+ /**
+ * print all stack frames between the frames which match start and end to System.out preceded by prefix
+ * by calling traceStackMatching(from, to, null, "out")
+ */
+
+ public void traceStackBetween(String from, String to, String prefix)
+ {
+ traceStackBetween(from, to, null, "out");
+ }
+
+ /**
+ * print all stack frames between the frames which match start and end to the trace stream identified by key
+ * preceded by prefix.
+ *
+ * @param from a pattern which identifies the first frame which should be printed. from will be matched against
+ * the concatenated classname and method name of each successive stack frame by calling String.matches().
+ * If null is supplied then the trigger frame will be used as the first frame to print. If a non-null value
+ * is supplied and no match is foudn then no farmes will be printed.
+ * @param to a pattern which identifies the last frame which should be printed. to will be matched against
+ * the concatenated classname and method name of each successive stack frame by calling String.matches().
+ * If null is supplied or no match is found then the bottom frame will be used as the last frame to print.
+ * @param prefix a String to be printed once before printing each line of stack trace. if supplied as null
+ * then the prefix "Stack trace (restricted) for " + Thread.currentThread().getName() + "\n" is used
+ * @param key an object identifying the trace stream to which output should be generated
+ */
+
+ public void traceStackBetween(String from, String to, String prefix, Object key)
+ {
+ StringBuffer buffer = new StringBuffer();
+ int l = stack.length;
+ int i = triggerIndex();
+ if (i < 0) {
+ return;
+ }
+
+ int first;
+ if (from != null) {
+ first = matchIndex(from, i, l);
+ if (first < 0) {
+ return;
+ }
+ } else {
+ first = i;
+ }
+
+ int last;
+ if (to != null) {
+ last = matchIndex(to, first + 1, l);
+ if (last < 0) {
+ last = l - 1;
+ }
+ } else {
+ last = l - 1;
+ }
+
+ if (prefix != null) {
+ buffer.append(prefix);
+ } else {
+ buffer.append("Stack trace (restricted) for ");
+ buffer.append(Thread.currentThread().getName());
+ buffer.append('\n');
+ }
+ for (i = first; i < last; i++) {
+ printlnFrame(buffer, i);
+ }
+
+ trace(key, buffer.toString());
+ }
+
+ /**
+ * print a stack trace of all threads in the system to System.out by calling traceStacks("out")
+ */
+ public void traceAllStacks()
+ {
+ traceAllStacks("out");
+ }
+
+ /**
+ * print a stack trace of all threads in the system to the trace stream keyed by key
+ */
+ public void traceAllStacks(String key)
+ {
+ StringBuffer buffer = new StringBuffer();
+ if (threadMXBean != null) {
+ ThreadInfo[] threadInfo = threadMXBean.dumpAllThreads(threadMXBean.isObjectMonitorUsageSupported(), threadMXBean.isSynchronizerUsageSupported());
+ for (int i = 0; i < threadInfo.length; i++) {
+ buffer.append(threadInfo[i].toString());
+ }
+ } else {
+ Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
+ for (Map.Entry<Thread, StackTraceElement[]> entry : map.entrySet()) {
+ Thread thread = entry.getKey();
+ StackTraceElement[] stack = entry.getValue();
+ int l = stack.length;
+ int i = 0;
+ buffer.append("Stack trace for thread ");
+ buffer.append(Thread.currentThread().getName());
+ buffer.append('\n');
+ for (; i < l; i++) {
+ printlnFrame(buffer, i);
+ }
+ buffer.append('\n');
+ }
+ }
+ trace(key, buffer.toString());
+ }
+
+ private static ThreadMXBean threadMXBean = initThreadMXBean();
+
+ private static ThreadMXBean initThreadMXBean() {
+ try {
+ return AccessController.doPrivileged(
+ new PrivilegedExceptionAction<ThreadMXBean>() {
+ public ThreadMXBean run() throws Exception {
+ return ManagementFactory.getThreadMXBean();
+ }
+ });
+ } catch (Exception exp) {
+ throw new UnsupportedOperationException(exp);
+ }
+ }
+
+}
\ No newline at end of file
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,164 +0,0 @@
-package org.jboss.byteman.sample.helper;
-
-import org.jboss.byteman.rule.Rule;
-
-/**
- * Helper class used by ThreadMonitorHelper script to trace thread operations
- */
-public class ThreadMonitorHelper extends StackTraceHelper
-{
- protected ThreadMonitorHelper(Rule rule) {
- super(rule);
- }
-
- /**
- * trace creation of the supplied thread to System.out
- *
- * this should only be triggered from the constructor for class java.lang.Thread"
- *
- * @param thread the newly created thread
- */
- public void traceCreate(Thread thread)
- {
- traceCreate(thread, "out");
- }
- /**
- * trace creation of the supplied thread to the trace stream identified by key
- *
- * @param thread the newly created thread
- * @param key an object identifying the trace stream to which output should be generated
- */
- public void traceCreate(Thread thread, Object key)
- {
- StringBuffer buffer = new StringBuffer();
- int l = stack.length;
- int t = triggerIndex();
- if (t < 0) {
- return;
- }
-
- int i = matchIndex("java.lang.Thread.<init>", t, l);
- if (i < 0) {
- // illegal usage
- traceStack("ThreadMonitorHelper.traceCreate : should only be triggered below Thread.<init>\n", key);
- return;
- }
- buffer.append("*** Thread create ");
- buffer.append(thread.getName());
- buffer.append(" ");
- buffer.append(thread.getClass().getCanonicalName());
- buffer.append('\n');
-
- // find bottommost constructor invocation
- i++;
- while (i < l && matchIndex(".*<init>", i, i) >= 0) {
- i++;
- }
- if (i == l) {
- // happens when a system thread is created by the runtime
- buffer.append(" from VM runtime\n");
- } else {
- buffer.append(" from ");
- printlnFrame(buffer, i);
- }
- trace(key, buffer.toString());
- }
-
- /**
- * trace start of the supplied thread to System.out
- *
- * this should only be triggered from the call to java.lang.Thread.start"
- *
- * @param thread the newly starting thread
- */
- public void traceStart(Thread thread)
- {
- traceStart(thread, "out");
- }
-
- /**
- * trace start of the supplied thread to the trace stream identified by key
- *
- * this should only be triggered from the call to java.lang.Thread.start"
- *
- * @param thread the newly starting thread
- * @param key an object identifying the trace stream to which output should be generated
- */
- public void traceStart(Thread thread, Object key)
- {
- StringBuffer buffer = new StringBuffer();
- int l = stack.length;
- int t = triggerIndex();
- if (t < 0) {
- return;
- }
-
- int i = matchIndex("java.lang.Thread.start", t, l);
- if (i < 0) {
- // illegal usage
- traceStack("ThreadMonitorHelper.traceStart : should only be triggered below Thread.start\n", key);
- return;
- }
-
- buffer.append("*** Thread start ");
- buffer.append(thread.getName());
- buffer.append(" ");
- buffer.append(thread.getClass().getCanonicalName());
- buffer.append('\n');
- StackTraceElement[] stack = Thread.currentThread().getStackTrace();
-
- if (++i == l) {
- // should not happen
- traceStack("ThreadMonitorHelper.traceStart : failed to find frame for caller of start\n", key);
- return;
- }
-
- buffer.append(" from ");
- printlnFrame(buffer, i);
- trace(key, buffer.toString());
- }
-
- /**
- * trace exit of the supplied thread to System.out
- *
- * this should only be triggered from the call to java.lang.Thread.exit"
- *
- * @param thread the exiting thread
- */
- public void traceExit(Thread thread)
- {
- traceExit(thread, "out");
- }
-
- /**
- * trace exit of the supplied thread to the trace stream identified by key
- *
- * this should only be triggered from the call to java.lang.Thread.exit"
- *
- * @param thread the exiting thread
- * @param key an object identifying the trace stream to which output should be generated
- */
- public void traceExit(Thread thread, Object key)
- {
- StringBuffer buffer = new StringBuffer();
- int l = stack.length;
- int t = triggerIndex();
- if (triggerIndex() < 0) {
- return;
- }
- int i = matchIndex("java.lang.Thread.exit", t, l);
- if (i < 0) {
- // illegal usage
- traceStack("ThreadMonitorHelper.traceExit : should only be triggered below Thread.exit\n", key);
- return;
- }
-
- buffer.append("*** Thread exit ");
- buffer.append(thread.getName());
- buffer.append(" ");
- buffer.append(thread.getClass().getCanonicalName());
- buffer.append('\n');
-
- trace(key, buffer.toString());
- }
-}
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/sample/src/org/jboss/byteman/sample/helper/ThreadMonitorHelper.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,164 @@
+package org.jboss.byteman.sample.helper;
+
+import org.jboss.byteman.rule.Rule;
+
+/**
+ * Helper class used by ThreadMonitorHelper script to trace thread operations
+ */
+public class ThreadMonitorHelper extends StackTraceHelper
+{
+ protected ThreadMonitorHelper(Rule rule) {
+ super(rule);
+ }
+
+ /**
+ * trace creation of the supplied thread to System.out
+ *
+ * this should only be triggered from the constructor for class java.lang.Thread"
+ *
+ * @param thread the newly created thread
+ */
+ public void traceCreate(Thread thread)
+ {
+ traceCreate(thread, "out");
+ }
+ /**
+ * trace creation of the supplied thread to the trace stream identified by key
+ *
+ * @param thread the newly created thread
+ * @param key an object identifying the trace stream to which output should be generated
+ */
+ public void traceCreate(Thread thread, Object key)
+ {
+ StringBuffer buffer = new StringBuffer();
+ int l = stack.length;
+ int t = triggerIndex();
+ if (t < 0) {
+ return;
+ }
+
+ int i = matchIndex("java.lang.Thread.<init>", t, l);
+ if (i < 0) {
+ // illegal usage
+ traceStack("ThreadMonitorHelper.traceCreate : should only be triggered below Thread.<init>\n", key);
+ return;
+ }
+ buffer.append("*** Thread create ");
+ buffer.append(thread.getName());
+ buffer.append(" ");
+ buffer.append(thread.getClass().getCanonicalName());
+ buffer.append('\n');
+
+ // find bottommost constructor invocation
+ i++;
+ while (i < l && matchIndex(".*<init>", i, i) >= 0) {
+ i++;
+ }
+ if (i == l) {
+ // happens when a system thread is created by the runtime
+ buffer.append(" from VM runtime\n");
+ } else {
+ buffer.append(" from ");
+ printlnFrame(buffer, i);
+ }
+ trace(key, buffer.toString());
+ }
+
+ /**
+ * trace start of the supplied thread to System.out
+ *
+ * this should only be triggered from the call to java.lang.Thread.start"
+ *
+ * @param thread the newly starting thread
+ */
+ public void traceStart(Thread thread)
+ {
+ traceStart(thread, "out");
+ }
+
+ /**
+ * trace start of the supplied thread to the trace stream identified by key
+ *
+ * this should only be triggered from the call to java.lang.Thread.start"
+ *
+ * @param thread the newly starting thread
+ * @param key an object identifying the trace stream to which output should be generated
+ */
+ public void traceStart(Thread thread, Object key)
+ {
+ StringBuffer buffer = new StringBuffer();
+ int l = stack.length;
+ int t = triggerIndex();
+ if (t < 0) {
+ return;
+ }
+
+ int i = matchIndex("java.lang.Thread.start", t, l);
+ if (i < 0) {
+ // illegal usage
+ traceStack("ThreadMonitorHelper.traceStart : should only be triggered below Thread.start\n", key);
+ return;
+ }
+
+ buffer.append("*** Thread start ");
+ buffer.append(thread.getName());
+ buffer.append(" ");
+ buffer.append(thread.getClass().getCanonicalName());
+ buffer.append('\n');
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+
+ if (++i == l) {
+ // should not happen
+ traceStack("ThreadMonitorHelper.traceStart : failed to find frame for caller of start\n", key);
+ return;
+ }
+
+ buffer.append(" from ");
+ printlnFrame(buffer, i);
+ trace(key, buffer.toString());
+ }
+
+ /**
+ * trace exit of the supplied thread to System.out
+ *
+ * this should only be triggered from the call to java.lang.Thread.exit"
+ *
+ * @param thread the exiting thread
+ */
+ public void traceExit(Thread thread)
+ {
+ traceExit(thread, "out");
+ }
+
+ /**
+ * trace exit of the supplied thread to the trace stream identified by key
+ *
+ * this should only be triggered from the call to java.lang.Thread.exit"
+ *
+ * @param thread the exiting thread
+ * @param key an object identifying the trace stream to which output should be generated
+ */
+ public void traceExit(Thread thread, Object key)
+ {
+ StringBuffer buffer = new StringBuffer();
+ int l = stack.length;
+ int t = triggerIndex();
+ if (triggerIndex() < 0) {
+ return;
+ }
+ int i = matchIndex("java.lang.Thread.exit", t, l);
+ if (i < 0) {
+ // illegal usage
+ traceStack("ThreadMonitorHelper.traceExit : should only be triggered below Thread.exit\n", key);
+ return;
+ }
+
+ buffer.append("*** Thread exit ");
+ buffer.append(thread.getName());
+ buffer.append(" ");
+ buffer.append(thread.getClass().getCanonicalName());
+ buffer.append('\n');
+
+ trace(key, buffer.toString());
+ }
+}
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Main.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Main.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Main.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -47,10 +47,14 @@
if (args != null) {
// args are supplied eparated by ',' characters
String[] argsArray = args.split(",");
- // the only args we accept are extra jar files to be added to the boot path or scanned for rules
+ // we accept extra jar files to be added to the boot/sys classpaths
+ // script files to be scanned for rules
+ // listener flag which implies use of a retransformer
for (String arg : argsArray) {
if (arg.startsWith(BOOT_PREFIX)) {
bootJarPaths.add(arg.substring(BOOT_PREFIX.length(), arg.length()));
+ } else if (arg.startsWith(SYS_PREFIX)) {
+ sysJarPaths.add(arg.substring(SYS_PREFIX.length(), arg.length()));
} else if (arg.startsWith(SCRIPT_PREFIX)) {
scriptPaths.add(arg.substring(SCRIPT_PREFIX.length(), arg.length()));
} else if (arg.startsWith(LISTENER_PREFIX)) {
@@ -63,13 +67,12 @@
} else {
System.err.println("org.jboss.byteman.agent.Main:\n" +
" illegal agent argument : " + arg + "\n" +
- " valid arguments are boot:<path-to-jar>, script:<path-to-script> or listener:<true-or-false>");
+ " valid arguments are boot:<path-to-jar>, sys:<path-to-jar>, script:<path-to-script> or listener:<true-or-false>");
}
}
}
// add any boot jars to the boot class path
- // TODO can only do this when we get to 1.6
for (String bootJarPath : bootJarPaths) {
try {
@@ -81,6 +84,18 @@
}
}
+ // add any sys jars to the system class path
+
+ for (String sysJarPath : sysJarPaths) {
+ try {
+ JarFile jarfile = new JarFile(new File(sysJarPath));
+ inst.appendToSystemClassLoaderSearch(jarfile);
+ } catch (IOException ioe) {
+ System.err.println("org.jboss.byteman.agent.Main: unable to open system jar file : " + sysJarPath);
+ throw ioe;
+ }
+ }
+
// look up rules in any script files
for (String scriptPath : scriptPaths) {
@@ -127,13 +142,13 @@
if (Transformer.isVerbose()) {
System.out.println("Adding retransformer");
}
- transformerClazz = loader.loadClass("org.jboss.byteman.agent.Transformer");
+ transformerClazz = loader.loadClass("org.jboss.byteman.agent.Retransformer");
//transformer = new Retransformer(inst, scriptPaths, scripts, true);
} else {
if (Transformer.isVerbose()) {
System.out.println("Adding transformer");
}
- transformerClazz = loader.loadClass("org.jboss.byteman.agent.Retransformer");
+ transformerClazz = loader.loadClass("org.jboss.byteman.agent.Transformer");
//transformer = new Transformer(inst, scriptPaths, scripts, isRedefine);
}
@@ -154,6 +169,11 @@
private static final String BOOT_PREFIX = "boot:";
/**
+ * prefix used to specify system jar argument for agent
+ */
+ private static final String SYS_PREFIX = "sys:";
+
+ /**
* prefix used to specify script argument for agent
*/
@@ -177,6 +197,11 @@
private static List<String> bootJarPaths = new ArrayList<String>();
/**
+ * list of paths to extra system jars supplied on command line
+ */
+ private static List<String> sysJarPaths = new ArrayList<String>();
+
+ /**
* list of paths to script files supplied on command line
*/
private static List<String> scriptPaths = new ArrayList<String>();
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Retransformer.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Retransformer.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Retransformer.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -25,6 +25,7 @@
import java.lang.instrument.Instrumentation;
import java.util.*;
+import java.util.jar.JarFile;
import java.io.PrintWriter;
/**
@@ -45,7 +46,7 @@
addTransformListener();
}
- protected void installScript(List<String> scriptTexts, List<String> scriptNames) throws Exception
+ protected void installScript(List<String> scriptTexts, List<String> scriptNames, PrintWriter out) throws Exception
{
int length = scriptTexts.size();
List<RuleScript> toBeAdded = new LinkedList<RuleScript>();
@@ -70,15 +71,15 @@
RuleScript previous;
- synchronized (nameToScriptMap) {
- previous = nameToScriptMap.get(name);
- if (previous != null) {
- System.out.println("redefining rule " + name);
- toBeRemoved.add(previous);
- previous.setDeleted();
- }
- nameToScriptMap.put(name, ruleScript);
+ previous = nameToScriptMap.get(name);
+ if (previous != null) {
+ out.println("redefining rule " + name);
+ toBeRemoved.add(previous);
+ previous.setDeleted();
+ } else {
+ out.println("install rule " + name);
}
+ nameToScriptMap.put(name, ruleScript);
// remove any old scripts and install the new ones to ensure that
// automatic loads do the right thing
@@ -112,6 +113,26 @@
// ok, now that we have updated the maps we need to find all classes which match the scripts and
// retransform them
+ // list all class names for the to be aded and to be removed scripts
+
+ List<String> affectedClassNames = new LinkedList<String>();
+
+ for (RuleScript ruleScript : toBeAdded) {
+ String targetClassName = ruleScript.getTargetClass();
+ if (!affectedClassNames.contains(targetClassName)) {
+ affectedClassNames.add(targetClassName);
+ }
+ }
+
+ for (RuleScript ruleScript : toBeRemoved) {
+ String targetClassName = ruleScript.getTargetClass();
+ if (!affectedClassNames.contains(targetClassName)) {
+ affectedClassNames.add(targetClassName);
+ }
+ }
+
+ // now look for loaded classes whose names are in the list
+
List<Class<?>> transformed = new LinkedList<Class<?>>();
for (Class clazz : inst.getAllLoadedClasses()) {
@@ -122,9 +143,10 @@
continue;
}
- if (targetToScriptMap.containsKey(name)) {
+ // TODO only retransform classes for which rules have been added or removed
+ if (affectedClassNames.contains(name)) {
transformed.add(clazz);
- } else if (lastDot >= 0 && targetToScriptMap.containsKey(name.substring(lastDot+1))) {
+ } else if (lastDot >= 0 && affectedClassNames.contains(name.substring(lastDot+1))) {
transformed.add(clazz);
}
}
@@ -135,28 +157,32 @@
Class<?>[] transformedArray = new Class<?>[transformed.size()];
inst.retransformClasses(transformed.toArray(transformedArray));
}
+
+ // now we can safely purge keys for all deleted scripts
+
+ for (RuleScript ruleScript : toBeRemoved) {
+ ruleScript.purge();
+ }
}
protected void listScripts(PrintWriter out) throws Exception
{
- synchronized (nameToScriptMap) {
- Iterator<RuleScript> iterator = nameToScriptMap.values().iterator();
+ Iterator<RuleScript> iterator = nameToScriptMap.values().iterator();
- if (!iterator.hasNext()) {
- out.println("no rules installed");
- } else {
- while (iterator.hasNext()) {
- RuleScript ruleScript = iterator.next();
- ruleScript.writeTo(out);
- synchronized (ruleScript) {
- List<Transform> transformed = ruleScript.getTransformed();
- if (transformed != null) {
- Iterator<Transform> iter = transformed.iterator();
- while (iter.hasNext()) {
- Transform transform = iter.next();
- transform.writeTo(out);
- }
+ if (!iterator.hasNext()) {
+ out.println("no rules installed");
+ } else {
+ while (iterator.hasNext()) {
+ RuleScript ruleScript = iterator.next();
+ ruleScript.writeTo(out);
+ synchronized (ruleScript) {
+ List<Transform> transformed = ruleScript.getTransformed();
+ if (transformed != null) {
+ Iterator<Transform> iter = transformed.iterator();
+ while (iter.hasNext()) {
+ Transform transform = iter.next();
+ transform.writeTo(out);
}
}
}
@@ -168,4 +194,140 @@
{
TransformListener.initialize(this);
}
+
+ public void removeScripts(List<String> scriptTexts, PrintWriter out) throws Exception
+ {
+ List<RuleScript> toBeRemoved = new LinkedList<RuleScript>();
+
+ if (scriptTexts != null) {
+ int length = scriptTexts.size();
+ for (int i = 0; i < length ; i++) {
+ String scriptText = scriptTexts.get(i);
+ String[] lines = scriptText.split("\n");
+ for (int j = 0; j < lines.length; j++) {
+ String line = lines[j].trim();
+ if (line.startsWith("RULE ")) {
+ String name = line.substring(5).trim();
+ RuleScript ruleScript = nameToScriptMap.get(name);
+ if (ruleScript == null) {
+ out.print("ERROR failed to find loaded rule with name ");
+ out.println(name);
+ } else if (toBeRemoved.contains(ruleScript)) {
+ out.print("WARNING duplicate occurence for rule name ");
+ out.println(name);
+ } else {
+ toBeRemoved.add(ruleScript);
+ }
+ }
+ }
+ }
+ } else {
+ toBeRemoved.addAll(nameToScriptMap.values());
+ }
+
+ if (toBeRemoved.isEmpty()) {
+ out.println("ERROR No rule scripts to remove");
+ return;
+ }
+
+ for (RuleScript ruleScript : toBeRemoved) {
+ String name = ruleScript.getName();
+ String targetClassName = ruleScript.getTargetClass();
+ String baseName = null;
+ int lastDotIdx = targetClassName.lastIndexOf('.');
+ if (lastDotIdx >= 0) {
+ baseName = targetClassName.substring(lastDotIdx + 1);
+ }
+
+ // update the name to script map to remove the entry for this rule
+
+ nameToScriptMap.remove(name);
+
+ // invalidate the script first then delete it from the target map
+ // so it is no longer used to do any transformatuion of classes
+
+ ruleScript.setDeleted();
+
+ synchronized(targetToScriptMap) {
+ List<RuleScript> list = targetToScriptMap.get(targetClassName);
+ if (list != null) {
+ list.remove(ruleScript);
+ if (list.isEmpty()) {
+ targetToScriptMap.remove(targetClassName);
+ }
+ }
+ if (baseName != null) {
+ list = targetToScriptMap.get(baseName);
+ if (list != null) {
+ list.remove(ruleScript);
+ if (list.isEmpty()) {
+ targetToScriptMap.remove(baseName);
+ }
+ }
+ }
+ }
+ }
+
+ // ok, now that we have updated the maps we need to find all classes which match the scripts and
+ // retransform them
+
+ // list all class names for the to be removed scripts
+
+ List<String> affectedClassNames = new LinkedList<String>();
+
+ for (RuleScript ruleScript : toBeRemoved) {
+ String targetClassName = ruleScript.getTargetClass();
+ if (!affectedClassNames.contains(targetClassName)) {
+ affectedClassNames.add(targetClassName);
+ }
+ }
+
+ // now look for loaded classes whose names are in the list
+
+ List<Class<?>> transformed = new LinkedList<Class<?>>();
+
+ for (Class clazz : inst.getAllLoadedClasses()) {
+ String name = clazz.getName();
+ int lastDot = name.lastIndexOf('.');
+
+ if (isBytemanClass(name) || !isTransformable(name)) {
+ continue;
+ }
+
+ // retransform if this class has been affected by the delete
+
+ if (affectedClassNames.contains(name)) {
+ transformed.add(clazz);
+ } else if (lastDot >= 0 && affectedClassNames.contains(name.substring(lastDot+1))) {
+ transformed.add(clazz);
+ }
+ }
+
+ // retransform all classes affected by the change
+
+ if (!transformed.isEmpty()) {
+ Class<?>[] transformedArray = new Class<?>[transformed.size()];
+ inst.retransformClasses(transformed.toArray(transformedArray));
+ }
+
+ // now we can safely purge keys for all the deleted scripts -- we need to do this
+ // after the retransform because the latter removes the trigger code which uses
+ // the rule key
+
+ for (RuleScript ruleScript : toBeRemoved) {
+ ruleScript.purge();
+ out.println("uninstall RULE " + ruleScript.getName());
+ }
+ }
+
+ public void appendJarFile(PrintWriter out, JarFile jarfile, boolean isBoot) throws Exception
+ {
+ if (isBoot) {
+ inst.appendToBootstrapClassLoaderSearch(jarfile);
+ out.println("append boot jar " + jarfile.getName());
+ } else {
+ inst.appendToSystemClassLoaderSearch(jarfile);
+ out.println("append sys jar " + jarfile.getName());
+ }
+ }
}
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/RuleScript.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/RuleScript.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/RuleScript.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -206,16 +206,18 @@
*/
public synchronized void purge()
{
- int count = transformed.size();
- for (int i = 0; i < count; i++) {
- Transform transform = transformed.get(i);
- Rule rule = transform.getRule();
- if (rule != null) {
- rule.purge();
+ if (transformed != null) {
+ int count = transformed.size();
+ for (int i = 0; i < count; i++) {
+ Transform transform = transformed.get(i);
+ Rule rule = transform.getRule();
+ if (rule != null) {
+ rule.purge();
+ }
}
}
}
-
+
public String toString()
{
StringWriter stringWriter = new StringWriter();
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/TransformListener.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/TransformListener.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/TransformListener.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,6 +1,7 @@
package org.jboss.byteman.agent;
import org.jboss.byteman.agent.Retransformer;
+import org.jboss.byteman.rule.Rule;
import java.net.ServerSocket;
import java.net.Socket;
@@ -8,6 +9,7 @@
import java.io.*;
import java.util.List;
import java.util.LinkedList;
+import java.util.jar.JarFile;
/**
* a socket based listener class which reads scripts from stdin and installs them in the current runtime
@@ -31,6 +33,9 @@
try {
theServerSocket = new ServerSocket();
theServerSocket.bind(new InetSocketAddress("localhost", DEFAULT_PORT));
+ if (Transformer.isVerbose()) {
+ System.out.println("TransformListener() : accepting requests on port " + DEFAULT_PORT);
+ }
} catch (IOException e) {
System.out.println("TransformListener() : unexpected exception opening server socket " + e);
e.printStackTrace();
@@ -46,9 +51,17 @@
public static synchronized boolean terminate()
{
+ // we don't want the listener shutdown to be aborted because of triggered rules
+ boolean enabled = true;
+ try {
+ enabled = Rule.disableTriggers();
+
if (theTransformListener != null) {
try {
theServerSocket.close();
+ if (Transformer.isVerbose()) {
+ System.out.println("TransformListener() : closing port " + DEFAULT_PORT);
+ }
} catch (IOException e) {
// ignore -- the thread should exit anyway
}
@@ -63,10 +76,19 @@
}
return true;
+ } finally {
+ if (enabled) {
+ Rule.enableTriggers();
+ }
+ }
}
public void run()
{
+ // we don't want to see any triggers in the listener thread
+
+ Rule.disableTriggers();
+
while (true) {
if (theServerSocket.isClosed()) {
return;
@@ -82,6 +104,9 @@
return;
}
+ if (Transformer.isVerbose()) {
+ System.out.println("TransformListener() : handling connection on port " + socket.getLocalPort());
+ }
handleConnection(socket);
}
}
@@ -136,14 +161,23 @@
out.println("ERROR");
out.println("Expecting input command");
out.println("OK");
+ } else if (line.equals("BOOT")) {
+ loadJars(in, out, true);
+ } else if (line.equals("SYS")) {
+ loadJars(in, out, false);
} else if (line.equals("LOAD")) {
loadScripts(in, out);
+ } else if (line.equals("DELETE")) {
+ deleteScripts(in, out);
} else if (line.equals("LIST")) {
listScripts(in, out);
+ } else if (line.equals("DELETEALL")) {
+ purgeScripts(in, out);
} else {
out.println("ERROR");
out.println("Unexpected command " + line);
out.println("OK");
+ out.flush();
}
} catch (Exception e) {
System.out.println("TransformListener.run : exception " + e + " processing command " + line);
@@ -159,6 +193,40 @@
private void loadScripts(BufferedReader in, PrintWriter out) throws IOException
{
+ handleScripts(in, out, false);
+ }
+
+ private void loadJars(BufferedReader in, PrintWriter out, boolean isBoot) throws IOException
+ {
+ String line = in.readLine().trim();
+ while (line != null && !line.equals("ENDBOOT")) {
+ try {
+ JarFile jarfile = new JarFile(new File(line));
+ retransformer.appendJarFile(out, jarfile, isBoot);
+ } catch (Exception e) {
+ out.append("EXCEPTION ");
+ out.append("Unable to add jar file " + line + "\n");
+ out.append(e.toString());
+ out.append("\n");
+ e.printStackTrace(out);
+ }
+ line = in.readLine().trim();
+ }
+ if (line == null || !line.equals("ENDBOOT")) {
+ out.append("ERROR\n");
+ out.append("Unexpected end of line reading boot jars\n");
+ }
+ out.println("OK");
+ out.flush();
+ }
+
+ private void deleteScripts(BufferedReader in, PrintWriter out) throws IOException
+ {
+ handleScripts(in, out, true);
+ }
+
+ private void handleScripts(BufferedReader in, PrintWriter out, boolean doDelete) throws IOException
+ {
List<String> scripts = new LinkedList<String>();
List<String> scriptNames = new LinkedList<String>();
@@ -187,8 +255,9 @@
}
line = in.readLine();
-
- if (!line.equals("ENDLOAD")) {
+
+ if ((doDelete && !line.equals("ENDDELETE")) ||
+ (!doDelete && !line.equals("ENDLOAD"))) {
out.append("ERROR ");
out.append("Unexpected end of line reading script " + scriptName + "\n");
out.println("OK");
@@ -197,19 +266,28 @@
}
try {
- retransformer.installScript(scripts, scriptNames);
- out.println("OK");
- out.flush();
+ if (doDelete) {
+ retransformer.removeScripts(scripts, out);
+ } else {
+ retransformer.installScript(scripts, scriptNames, out);
+ }
} catch (Exception e) {
out.append("EXCEPTION ");
out.append(e.toString());
out.append('\n');
e.printStackTrace(out);
- out.println("OK");
- out.flush();
}
+ out.println("OK");
+ out.flush();
}
+ private void purgeScripts(BufferedReader in, PrintWriter out) throws Exception
+ {
+ retransformer.removeScripts(null, out);
+ out.println("OK");
+ out.flush();
+ }
+
private void listScripts(BufferedReader in, PrintWriter out) throws Exception
{
retransformer.listScripts(out);
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Transformer.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Transformer.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/Transformer.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -45,13 +45,6 @@
*/
public class Transformer implements ClassFileTransformer {
- private static Transformer theTransformer = null;
-
- public static Transformer getTheTransformer()
- {
- return theTransformer;
- }
-
/**
* constructor allowing this transformer to be provided with access to the JVM's instrumentation
* implementation
@@ -61,7 +54,6 @@
public Transformer(Instrumentation inst, List<String> scriptPaths, List<String> scriptTexts, boolean isRedefine)
throws Exception
{
- theTransformer = this;
this.inst = inst;
this.isRedefine = isRedefine;
targetToScriptMap = new HashMap<String, List<RuleScript>>();
@@ -173,16 +165,14 @@
{
String name = ruleScript.getName();
- synchronized (nameToScriptMap) {
- RuleScript old = nameToScriptMap.get(name);
- if (old != null) {
- throw new Exception("duplicated rule name " + name +
- " at ruleScript " + old.getFile() + " line " + old.getLine() +
- " and ruleScript " + ruleScript.getFile() + " line " + ruleScript.getLine());
- }
+ RuleScript old = nameToScriptMap.get(name);
+ if (old != null) {
+ throw new Exception("duplicated rule name " + name +
+ " at ruleScript " + old.getFile() + " line " + old.getLine() +
+ " and ruleScript " + ruleScript.getFile() + " line " + ruleScript.getLine());
+ }
- nameToScriptMap.put(name, ruleScript);
- }
+ nameToScriptMap.put(name, ruleScript);
}
protected void indexScriptByTarget(RuleScript ruleScript)
@@ -360,6 +350,10 @@
byte[] classfileBuffer)
throws IllegalClassFormatException
{
+ boolean enabled = true;
+ try {
+ enabled = Rule.disableTriggers();
+
byte[] newBuffer = classfileBuffer;
// we only transform certain classes -- we do allow bootstrap classes whose loader is null
// but we exclude byteman classes and java.lang classes
@@ -421,6 +415,11 @@
} else {
return null;
}
+ } finally {
+ if (enabled) {
+ Rule.enableTriggers();
+ }
+ }
}
/* switches controlling behaviour of transformer */
@@ -483,6 +482,11 @@
*/
public static final String DUMP_GENERATED_CLASSES = BYTEMAN_PACKAGE_PREFIX + "dump.generated.classes";
+ /**
+ * system property set to true in order to enable transform of java.lang classes
+ */
+ public static final String QUODLIBET = BYTEMAN_PACKAGE_PREFIX + "quodlibet";
+
/* implementation */
/**
@@ -575,6 +579,45 @@
}
/**
+ * disable triggering of rules inside the current thread
+ * @return true if triggering was previously enabled and false if it was already disabled
+ */
+ public static boolean disableTriggers()
+ {
+ Boolean enabled = isEnabled.get();
+ if (enabled == null) {
+ isEnabled.set(Boolean.FALSE);
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * enable triggering of rules inside the current thread
+ * @return true if triggering was previously enabled and false if it was already disabled
+ */
+ public static boolean enableTriggers()
+ {
+ Boolean enabled = isEnabled.get();
+ if (enabled != null) {
+ isEnabled.remove();
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * check if triggering of rules is enabled inside the current thread
+ * @return true if triggering is enabled and false if it is disabled
+ */
+ public static boolean isTriggeringEnabled()
+ {
+ return isEnabled.get() == null;
+ }
+
+ /**
* test whether a class with a given name is located in the byteman package
* @param className
* @return true if a class is located in the byteman package otherwise return false
@@ -641,7 +684,7 @@
return (className.startsWith(COM_ARJUNA_PACKAGE_PREFIX) || className.startsWith(ORG_JBOSS_PACKAGE_PREFIX));
*/
if (className.startsWith(JAVA_LANG_PACKAGE_PREFIX)) {
- return false;
+ return quodlibet;
}
return true;
@@ -686,12 +729,12 @@
private final static boolean dumpCFG = (dumpCFGPartial || (System.getProperty(DUMP_CFG) != null));
/**
- * switch to control verbose output during rule processing
+ * switch to control debug output during rule processing
*/
private final static boolean debug = (System.getProperty(DEBUG) != null);
/**
- * switch to control verbose output during rule processing
+ * switch to control whether rules are compiled ot bytecode or not
*/
private final static boolean compileToBytecode = (System.getProperty(COMPILE_TO_BYTECODE) != null);
@@ -705,6 +748,11 @@
*/
private final static String dumpGeneratedClassesDir;
+ /**
+ * switch to control whether transformations will be applied to java.lang.* classes
+ */
+ private final static boolean quodlibet = (System.getProperty(QUODLIBET) != null);
+
static {
String userDir = System.getProperty(DUMP_GENERATED_CLASSES_DIR);
if (userDir != null) {
@@ -719,19 +767,19 @@
}
}
- public void maybeDumpClass(String fullName, byte[] bytes)
+ public static void maybeDumpClass(String fullName, byte[] bytes)
{
if (dumpGeneratedClasses) {
dumpClass(fullName, bytes);
}
}
- private void dumpClass(String fullName, byte[] bytes)
+ private static void dumpClass(String fullName, byte[] bytes)
{
dumpClass(fullName, bytes, null);
}
- private void dumpClass(String fullName, byte[] bytes, byte[] oldBytes)
+ private static void dumpClass(String fullName, byte[] bytes, byte[] oldBytes)
{
int dotIdx = fullName.lastIndexOf('.');
@@ -766,7 +814,7 @@
}
}
- private boolean ensureDumpDirectory(String fileName)
+ private static boolean ensureDumpDirectory(String fileName)
{
File file = new File(fileName);
if (file.exists()) {
@@ -775,4 +823,9 @@
return file.mkdirs();
}
}
+ /**
+ * Thread local holding a per thread Boolean which is true if triggering is disabled and false if triggering is
+ * enabled
+ */
+ private static ThreadLocal<Boolean> isEnabled = new ThreadLocal<Boolean>();
}
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/submit/Submit.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/submit/Submit.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/agent/submit/Submit.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -4,10 +4,13 @@
import java.io.*;
import java.net.Socket;
+import java.util.ArrayList;
+import java.util.List;
/**
- * Provide a main routine for an app which submits a script to a byteman agent for installation in the JVM runtime
- * or, with no arguments, lists all currently installed scripts
+ * Provide a main routine for an app which communicates with the byteman agent at runtime allowing loading,
+ * reloading, unloading of rules and listing of the current rule set and any successful or failed attempts
+ * to inject, parse and typecheck the rules.
*/
public class Submit
{
@@ -15,31 +18,75 @@
* main routine which submits a script to the byteman agent
* @param args command line arguments specifying the script file(s) to be submitted and, optionally,
* the byteman agent listener port to use.
- * Submit [- port] [scriptfile . . .]
+ * Submit [-p port] [-l|-u] [scriptfile . . .]
+ * Submit [-p port] [-b|-s] jarfile . . .
+ * -p port specifies theport to use
+ * -l implies load/reload all rules found in supplied scripts
+ * or list all current rules if no scriptfile
+ * -u implies unload all rules found in supplied scripts
+ * or unload all rules if no scriptfile
+ * -b jarfile implies install jar files into boot class path
+ * -s jarfile implies install jar files into system class path
*/
public static void main(String[] args)
{
int port = TransformListener.DEFAULT_PORT;
int startIdx = 0;
int maxIdx = args.length;
+ boolean loadOrList = false;
+ boolean deleteRules = false;
+ boolean addBoot = false;
+ boolean addSys = false;
+ int optionCount = 0;
- if (maxIdx >= 2 && args[0].equals("-p")) {
- try {
- port = Integer.valueOf(args[1]);
- } catch (NumberFormatException e) {
- System.out.println("Submit : invalid port " + args[1]);
- System.exit(1);
+ while (startIdx < maxIdx && args[startIdx].startsWith("-")) {
+ if (maxIdx >= startIdx + 2 && args[startIdx].equals("-p")) {
+ try {
+ port = Integer.valueOf(args[1]);
+ } catch (NumberFormatException e) {
+ System.out.println("Submit : invalid port " + args[1]);
+ System.exit(1);
+ }
+ if (port <= 0) {
+ System.out.println("Submit : invalid port " + args[1]);
+ System.exit(1);
+ }
+ startIdx += 2;
+ } else if (args[startIdx].equals("-u")) {
+ deleteRules = true;
+ startIdx++;
+ optionCount++;
+ } else if (args[startIdx].equals("-l")) {
+ loadOrList = true;
+ startIdx++;
+ optionCount++;
+ } else if (args[startIdx].equals("-b")) {
+ addBoot = true;
+ startIdx ++;
+ optionCount++;
+ } else if (args[startIdx].equals("-b")) {
+ addSys = true;
+ startIdx ++;
+ optionCount++;
+ } else {
+ break;
}
- if (port <= 0) {
- System.out.println("Submit : invalid port " + args[1]);
- System.exit(1);
- }
- startIdx = 2;
}
- if (startIdx < maxIdx && args[startIdx].startsWith("-")) {
+
+ if (startIdx < maxIdx && args[startIdx].startsWith("-") || optionCount > 1) {
usage(1);
}
+ if (optionCount == 0) {
+ loadOrList = true;
+ }
+
+ // must have some file args if adding to sys or boot classpath
+
+ if (startIdx == maxIdx && (addBoot || addSys)) {
+ usage(1);
+ }
+
for (int i = startIdx; i < maxIdx; i++) {
File file = new File(args[i]);
if (!file.isFile() || !file.canRead()) {
@@ -99,12 +146,15 @@
char[] readBuffer = new char[READ_BUFFER_LENGTH];
if (startIdx == maxIdx) {
- // no args means list all current scripts;
- // !!! TODO -- invoke list command
- out.println("LIST");
+ // no args means list or delete all current scripts
+ if (deleteRules) {
+ out.println("DELETEALL");
+ } else {
+ out.println("LIST");
+ }
out.flush();
try {
- String line = in.readLine();
+ String line = in.readLine().trim();
while (line != null && !line.equals("OK"))
{
System.out.println(line);
@@ -124,40 +174,66 @@
}
} else {
StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append("LOAD\n");
- for (int i = startIdx; i < maxIdx; i++) {
- String name = args[i];
- stringBuffer.append("SCRIPT " + name + "\n");
- try {
- FileInputStream fis = new FileInputStream(args[i]);
- InputStreamReader reader = new InputStreamReader(fis);
- int read = reader.read(readBuffer);
- while (read > 0) {
- stringBuffer.append(readBuffer, 0, read);
- read = reader.read(readBuffer);
- }
- stringBuffer.append("ENDSCRIPT\n");
- } catch (IOException e) {
- System.out.println("Submit : error reading from file " + args[i] + " " + e);
- e.printStackTrace();
+ if (addBoot) {
+ stringBuffer.append("BOOT\n");
+ for (int i = startIdx; i < maxIdx; i++) {
+ String name = args[i];
+ stringBuffer.append(name);
+ stringBuffer.append("\n");
+ }
+ stringBuffer.append("ENDBOOT\n");
+ } else if (addSys) {
+ stringBuffer.append("BOOT\n");
+ for (int i = startIdx; i < maxIdx; i++) {
+ String name = args[i];
+ stringBuffer.append(name);
+ stringBuffer.append("\n");
+ }
+ stringBuffer.append("ENDBOOT\n");
+ } else {
+ if (deleteRules) {
+ stringBuffer.append("DELETE\n");
+ } else {
+ stringBuffer.append("LOAD\n");
+ }
+ for (int i = startIdx; i < maxIdx; i++) {
+ String name = args[i];
+ stringBuffer.append("SCRIPT " + name + "\n");
try {
- socket.close();
- } catch (IOException e1) {
- System.out.println("Submit : exception closing socket after failed file read " + e1);
- e1.printStackTrace();
+ FileInputStream fis = new FileInputStream(args[i]);
+ InputStreamReader reader = new InputStreamReader(fis);
+ int read = reader.read(readBuffer);
+ while (read > 0) {
+ stringBuffer.append(readBuffer, 0, read);
+ read = reader.read(readBuffer);
+ }
+ reader.close();
+ stringBuffer.append("ENDSCRIPT\n");
+ } catch (IOException e) {
+ System.out.println("Submit : error reading from file " + args[i] + " " + e);
+ e.printStackTrace();
+ try {
+ socket.close();
+ } catch (IOException e1) {
+ System.out.println("Submit : exception closing socket after failed file read " + e1);
+ e1.printStackTrace();
+ }
+
+ System.exit(1);
}
-
- System.exit(1);
}
+ if (deleteRules) {
+ stringBuffer.append("ENDDELETE\n");
+ } else {
+ stringBuffer.append("ENDLOAD\n");
+ }
}
- stringBuffer.append("ENDLOAD\n");
-
out.append(stringBuffer);
out.flush();
try {
- String line = in.readLine();
- while (line!= null & !line.equals("OK")) {
+ String line = in.readLine().trim();
+ while (line != null & !line.equals("OK")) {
System.out.println(line);
line = in.readLine();
}
@@ -178,9 +254,15 @@
public static void usage(int exitCode)
{
- System.out.println("usage : Submit [-p port] [scriptfile . . .]");
+ System.out.println("usage : Submit [-p port] [-l|-u] [scriptfile . . .]");
+ System.out.println(" Submit [-p port] [-b|-s] jarfile . . .");
System.out.println(" -p specifies listener port");
- System.out.println(" no args means list installed scripts");
+ System.out.println(" -l (default) with scriptfile(s) means load/reload all rules in scriptfile(s)");
+ System.out.println(" with no scriptfile means list all currently loaded rules");
+ System.out.println(" -u with scriptfile(s) means unload all rules in scriptfile(s)");
+ System.out.println(" with no scriptfile means unload all currently loaded rules");
+ System.out.println(" -b with jarfile(s) means add jars to bootstrap classpath");
+ System.out.println(" -s with jarfile(s) means add jars to system classpath");
System.exit(exitCode);
}
}
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/Rule.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/Rule.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/Rule.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -35,7 +35,6 @@
import org.jboss.byteman.rule.helper.Helper;
import org.jboss.byteman.rule.helper.InterpretedHelper;
import org.jboss.byteman.agent.Location;
-import org.jboss.byteman.agent.LocationType;
import org.jboss.byteman.agent.Transformer;
import org.jboss.byteman.agent.RuleScript;
import org.objectweb.asm.Opcodes;
@@ -261,7 +260,7 @@
public Type getReturnType()
{
return returnType;
- }
+ }
/**
* get the class loader of the target class for the rule
@@ -336,6 +335,33 @@
}
/**
+ * disable triggering of rules inside the current thread
+ * @return true if triggering was previously enabled and false if it was already disabled
+ */
+ public static boolean disableTriggers()
+ {
+ return Transformer.disableTriggers();
+ }
+
+ /**
+ * enable triggering of rules inside the current thread
+ * @return true if triggering was previously enabled and false if it was already disabled
+ */
+ public static boolean enableTriggers()
+ {
+ return Transformer.enableTriggers();
+ }
+
+ /**
+ * check if triggering of rules is enabled inside the current thread
+ * @return true if triggering is enabled and false if it is disabled
+ */
+ public static boolean isTriggeringEnabled()
+ {
+ return Transformer.isTriggeringEnabled();
+ }
+
+ /**
* typecheck and then compile this rule unless either action has been tried before
* @return true if the rule successfully type checks and then compiles under this call or a previous
* call or false if either operation has previously failed or fails under this call.
@@ -347,8 +373,12 @@
}
if (!checked) {
+ // ensure we don't trigger any code inside the type check or compile
+ // n.b. we may still allow recursive triggering while executing
+ boolean triggerEnabled = false;
String detail = "";
try {
+ triggerEnabled = disableTriggers();
typeCheck();
compile();
checked = true;
@@ -368,6 +398,11 @@
ce.printStackTrace(writer);
detail = stringWriter.toString();
System.out.println(detail);
+ } finally {
+ // be sure to return the status quo
+ if (triggerEnabled) {
+ enableTriggers();
+ }
}
ruleScript.recordCompile(triggerClass, loader, !checkFailed, detail);
@@ -493,6 +528,11 @@
*/
public static void execute(String key, Object recipient, Object[] args) throws ExecuteException
{
+ boolean enabled = isTriggeringEnabled();
+ if (!enabled) {
+ // we don't trigger code while we are doing rule housekeeping
+ return;
+ }
Rule rule = ruleKeyMap.get(key);
if (Transformer.isVerbose()) {
System.out.println("Rule.execute called for " + key);
@@ -563,6 +603,9 @@
} catch (Throwable throwable) {
System.out.println(getName() + " : " + throwable);
throw new ExecuteException(getName() + " : caught " + throwable, throwable);
+ } finally {
+ // restore the status quo -- we must have been enabled if we got to this method
+ enableTriggers();
}
}
}
@@ -685,6 +728,9 @@
{
return helperClass;
}
-
+
+ /**
+ * flag true if debugging of rule parsing is desired and false if it should not be performed
+ */
private static boolean debugParse = (System.getProperty("org.jboss.byteman.rule.debug") != null ? true : false);
}
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/compiler/Compiler.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/compiler/Compiler.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/compiler/Compiler.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -74,7 +74,7 @@
byte[] classBytes = compileBytes(rule, helperClass, helperName, compiledHelperName, compileToBytecode);
String externalName = compiledHelperName.replaceAll("/", ".");
// dump the compiled class bytes if required
- Transformer.getTheTransformer().maybeDumpClass(externalName, classBytes);
+ Transformer.maybeDumpClass(externalName, classBytes);
// ensure the class is loaded
// think we need to load the generated helper using the class loader of the trigger class
ClassLoader loader = rule.getLoader();
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ArithmeticExpression.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ArithmeticExpression.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ArithmeticExpression.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -283,8 +283,8 @@
operand0.compile(mv, currentStackHeights, maxStackHeights);
// do any required type conversion
compileTypeConversion(type0, type, mv, currentStackHeights, maxStackHeights);
- // compile lhs -- it adds 1 or 2 to the stack height
- currentStackHeights.addStackCount((type0.getNBytes() > 4 ? 2 : 1));
+ // compile rhs -- it adds 1 or 2 to the stack height
+ operand1.compile(mv, currentStackHeights, maxStackHeights);
// do any required type conversion
compileTypeConversion(type1, type, mv, currentStackHeights, maxStackHeights);
@@ -419,7 +419,7 @@
// check stack heights
if (currentStackHeights.stackCount != currentStack + expectedStack) {
- throw new CompileException("ArithmeticExpression.compile : invalid stack height " + currentStackHeights.stackCount + " expecting " + currentStack + expectedStack);
+ throw new CompileException("ArithmeticExpression.compile : invalid stack height " + currentStackHeights.stackCount + " expecting " + (currentStack + expectedStack));
}
// we needed room for 2 * expectedStack extra values on the stack -- make sure we got it
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/MethodExpression.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/MethodExpression.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/MethodExpression.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -29,6 +29,7 @@
import org.jboss.byteman.rule.exception.TypeException;
import org.jboss.byteman.rule.exception.ExecuteException;
import org.jboss.byteman.rule.exception.CompileException;
+import org.jboss.byteman.rule.exception.ThrowException;
import org.jboss.byteman.rule.Rule;
import org.jboss.byteman.rule.compiler.StackHeights;
import org.jboss.byteman.rule.helper.HelperAdapter;
@@ -42,6 +43,7 @@
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.InvocationTargetException;
/**
* an expression which identifies a method invocation
@@ -262,6 +264,13 @@
}
return method.invoke(recipientValue, argValues);
+ } catch (InvocationTargetException e) {
+ Throwable th = e.getCause();
+ if (th instanceof ExecuteException) {
+ throw (ExecuteException)th;
+ } else {
+ throw new ExecuteException("MethodExpression.interpret : exception invoking method " + token.getText() + getPos(), th);
+ }
} catch (ExecuteException e) {
throw e;
} catch (Exception e) {
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ReturnExpression.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ReturnExpression.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ReturnExpression.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -168,7 +168,7 @@
public void compile(MethodVisitor mv, StackHeights currentStackHeights, StackHeights maxStackHeights) throws CompileException
{
- Type returnType = (returnValue == null ? Type.VOID : returnValue.getType());
+ Type valueType = (returnValue == null ? Type.VOID : returnValue.getType());
int currentStack = currentStackHeights.stackCount;
int expected = 1;
int extraSlots = 0;
@@ -193,13 +193,17 @@
// stack any required return value or null -- adds 1 to stack but may use 2 slots
if (returnValue != null) {
returnValue.compile(mv, currentStackHeights, maxStackHeights);
- if (returnType.isPrimitive()) {
+ // we may need to convert from the value type to the return type
+ if (valueType != type) {
+ compileTypeConversion(valueType, type, mv, currentStackHeights, maxStackHeights);
+ }
+ if (type.isPrimitive()) {
// if the intermediate value used 2 words then at the peak we needed an extra stack slot
- if (returnType.getNBytes() > 4) {
+ if (valueType.getNBytes() > 4) {
extraSlots++;
}
// we need an object not a primitive
- compileBox(Type.boxType(returnType), mv, currentStackHeights, maxStackHeights);
+ compileBox(Type.boxType(type), mv, currentStackHeights, maxStackHeights);
}
} else {
// just push null
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ThrowExpression.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ThrowExpression.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/expression/ThrowExpression.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -101,7 +101,7 @@
type = Type.dereference(typeGroup.create(typeName));
- if (type.isUndefined()) {
+ if (type == null || type.isUndefined()) {
throw new TypeException("ThrowExpression.typeCheck : unknown exception type " + typeName + getPos());
}
@@ -153,11 +153,11 @@
}
if (candidates.isEmpty()) {
- throw new TypeException("ThrowExpression.typeCheck : invalid method for target class " + typeName + getPos());
+ throw new TypeException("ThrowExpression.typeCheck : invalid constructor for target class " + typeName + getPos());
}
if (candidates.size() > 1) {
- throw new TypeException("ThrowExpression.typeCheck : ambiguous method signature for target class " + typeName + getPos());
+ throw new TypeException("ThrowExpression.typeCheck : ambiguous constructor signature for target class " + typeName + getPos());
}
constructor = candidates.get(0);
@@ -340,9 +340,18 @@
}
public void writeTo(StringWriter stringWriter) {
- stringWriter.write("throw " + type.getName() + "(");
+ stringWriter.write("throw ");
+ if (type == null || Type.UNDEFINED == type) {
+ stringWriter.write(typeName);
+ } else {
+ stringWriter.write(type.getName());
+ }
+ String separator = "";
+ stringWriter.write("(");
for (Expression argument : arguments) {
+ stringWriter.write(separator);
argument.writeTo(stringWriter);
+ separator = ",";
}
stringWriter.write(")");
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/helper/Helper.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/helper/Helper.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/rule/helper/Helper.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -164,6 +164,16 @@
}
/**
+ * call trace("out, message").
+ * @param message
+ * @return true
+ */
+ public boolean trace(String message)
+ {
+ return trace("out", message);
+ }
+
+ /**
* write the supplied message to the trace stream identified by identifier, creating a new stream
* if none exists
* @param identifier an identifier used subsequently to identify the trace output stream
@@ -190,6 +200,16 @@
}
/**
+ * call traceln("out", message).
+ * @param message
+ * @return true
+ */
+ public boolean traceln(String message)
+ {
+ return traceln("out", message);
+ }
+
+ /**
* write the supplied message to the trace stream identified by identifier, creating a new stream
* if none exists, and append a new line
* @param identifier an identifier used subsequently to identify the trace output stream
@@ -433,9 +453,12 @@
// do nothing
}
}
- // remove the association between the waiter and the wait map
- removeWaiter(waiter);
}
+
+ // remove the association between the waiter and the wait map
+ synchronized (waitMap) {
+ removeWaiter(identifier);
+ }
return true;
}
}
@@ -515,9 +538,11 @@
// do nothing
}
}
- // remove the association between the waiter and the wait map
- removeWaiter(waiter);
}
+ // remove the association between the waiter and the wait map
+ synchronized (waitMap) {
+ removeWaiter(identifier);
+ }
return true;
}
}
@@ -882,6 +907,20 @@
}
/**
+ * enable or disable recursive triggering of rules by subsequent operations performed during binding,
+ * testing or firing of the current rule in the current thread.
+ * @param enabled true if triggering should be enabled or false if it should be disabled
+ */
+ public void setTriggering(boolean enabled)
+ {
+ if (enabled) {
+ Rule.enableTriggers();
+ } else {
+ Rule.disableTriggers();
+ }
+ }
+
+ /**
* return a unique name for the trigger point associated with this rule. n.b. a single rule may
* give rise to more than one trigger point if the rule applies to several methods with the same
* name or to several classes with the same (package unqualified) name, or even to several
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Joiner.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Joiner.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Joiner.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,3 +1,26 @@
+/*
+* 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.synchronization;
import java.util.List;
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Waiter.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Waiter.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/src/org/jboss/byteman/synchronization/Waiter.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -45,25 +45,31 @@
public void waitFor(long millisecs)
{
+ long start = System.currentTimeMillis();
+ long waitFor = millisecs == 0 ? 0 : millisecs;
synchronized(this) {
waiting = true;
-
- if (!signalled) {
+ while (!signalled && waitFor >= 0){
try {
- this.wait(millisecs);
+ this.wait(waitFor);
} catch (InterruptedException e) {
// ignore
}
- } else {
- // notify in case a signalling thread was waiting
- this.notifyAll();
+
+ if (!signalled)
+ {
+ waitFor = millisecs == 0 ? 0 : millisecs + start - System.currentTimeMillis();
+ }
}
+ if (signalled) {
+ // notify in case a signalling thread was waiting
+ this.notifyAll();
+ }
}
// if a signalKill was used then we have to throw an exception otherwise we just return
-
if (killed) {
- throw new ExecuteException("Waiter.waitFor waiting thread killed for " + waiterFor);
+ throw new ExecuteException("Waiter.waitFor : killed thread waiting for " + waiterFor);
}
}
@@ -126,4 +132,12 @@
*/
private boolean waiting;
+
+ /**
+ * getter for signalled flag
+ * @return signalled
+ */
+ public boolean isSignalled() {
+ return signalled;
+ }
}
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/build.xml
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/build.xml 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/build.xml 2009-10-20 15:47:20 UTC (rev 29698)
@@ -56,6 +56,7 @@
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="${javac.debug}">
<classpath>
+ <pathelement location="${byteman.home}/${byteman.jar}"/>
<pathelement location="${junit.home}/${junit.jar}"/>
</classpath>
</javac>
@@ -71,7 +72,7 @@
<delete dir="${build.dir}"/>
</target>
- <target name="tests" depends="jar, tests.location, tests.location.compiled, tests.javaops, tests.javaops.compiled, tests.bugfixes, tests.bugfixes.compiled"/>
+ <target name="tests" depends="jar, tests.location, tests.location.compiled, tests.javaops, tests.javaops.compiled, tests.misc, tests.misc.compiled, tests.bugfixes, tests.bugfixes.compiled"/>
<target name="tests.location">
<junit fork="true" showoutput="true">
@@ -321,6 +322,17 @@
<pathelement location="${junit.home}/${junit.jar}"/>
</classpath>
<jvmarg value="-javaagent:${byteman.home}/${byteman.jar}=script:${scripts.dir}/javaops/TestArithmetic.txt"/>
+ <!-- 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"/>
+ -->
+ <jvmarg value="-Dorg.jboss.byteman.compileToBytecode"/>
<test name="org.jboss.byteman.tests.javaops.TestArithmetic"/>
</junit>
<junit fork="true" showoutput="true">
@@ -402,11 +414,46 @@
<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.javaops.TestArray"/>
+ </junit>
+ </target>
+
+ <target name="tests.misc">
+ <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}/misc/TestRecursiveTriggers.txt"/>
+ <!--
+ <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.misc.TestRecursiveTriggers"/>
</junit>
</target>
+ <target name="tests.misc.compiled">
+ <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}/misc/TestRecursiveTriggers.txt"/>
+ <jvmarg value="-Dorg.jboss.byteman.compileToBytecode"/>
+ <!--
+ <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.misc.TestRecursiveTriggers"/>
+ </junit>
+ </target>
+
<target name="tests.bugfixes">
<junit fork="true" showoutput="true">
<classpath>
@@ -492,6 +539,27 @@
-->
<test name="org.jboss.byteman.tests.bugfixes.TestThrowAction"/>
</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/TestWaitAfterSignalWakeMustMeet.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.TestWaitAfterSignalWakeMustMeet"/>
+ </junit>
</target>
<target name="tests.bugfixes.compiled">
@@ -586,6 +654,28 @@
-->
<test name="org.jboss.byteman.tests.bugfixes.TestThrowAction"/>
</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/TestWaitAfterSignalWakeMustMeet.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.TestWaitAfterSignalWakeMustMeet"/>
+ </junit>
</target>
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/bugfixes/TestWaitAfterSignalWakeMustMeet.txt (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/bugfixes/TestWaitAfterSignalWakeMustMeet.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/bugfixes/TestWaitAfterSignalWakeMustMeet.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/bugfixes/TestWaitAfterSignalWakeMustMeet.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,123 @@
+##############################################################################
+# 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-38
+
+##############################################################################
+# when test is entered we need to set up a rendezvous
+
+RULE setup
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD test
+HELPER org.jboss.byteman.tests.helpers.TestWaitAfterSignalWakeMustMeetHelper
+IF TRUE
+DO createRendezvous("test", 2, true)
+ENDRULE
+
+
+##############################################################################
+# when ensureSignalWake is called we need to ensure that another thread has
+# called signalWake. our helper specialises signalWake to allow this to be
+# checked
+
+RULE ensureSignalWait
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD ensureSignalWake
+HELPER org.jboss.byteman.tests.helpers.TestWaitAfterSignalWakeMustMeetHelper
+IF TRUE
+DO ensureSignalWake()
+ENDRULE
+
+##############################################################################
+# when ensureWaitFor is called we need to ensure that another thread has
+# called waitFor. our helper specialises waitFor to allow this to be
+# checked
+
+RULE ensureWaitFor
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD ensureWaitFor
+HELPER org.jboss.byteman.tests.helpers.TestWaitAfterSignalWakeMustMeetHelper
+IF TRUE
+DO ensureWaitFor()
+ENDRULE
+
+##############################################################################
+# when triggerWaitFor is called we need to do a waitFor
+
+RULE triggerWaitFor
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD triggerWaitFor
+HELPER org.jboss.byteman.tests.helpers.TestWaitAfterSignalWakeMustMeetHelper
+BIND test : TestEmptySignature = $0
+IF TRUE
+DO test.log("waitFor"),
+ waitFor("test")
+ENDRULE
+
+##############################################################################
+# when triggerSignalWake is called we need to do a signalWake
+
+RULE triggerSignalWake
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD triggerSignalWake
+HELPER org.jboss.byteman.tests.helpers.TestWaitAfterSignalWakeMustMeetHelper
+BIND test : TestEmptySignature = $0
+IF TRUE
+DO test.log("signalWake"),
+ signalWake("test", true)
+ENDRULE
+
+##############################################################################
+# when triggerRendezvous is called we need to do a rendezvous
+
+RULE triggerRendezvous
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD triggerRendezvous
+HELPER org.jboss.byteman.tests.helpers.TestWaitAfterSignalWakeMustMeetHelper
+IF TRUE
+DO rendezvous("test")
+ENDRULE
+
+##############################################################################
+# when triggerTimeoutCheck is called we need to wait and, if we timeout
+# throw an Exception
+
+RULE triggerTimeoutCheck
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD triggerTimeoutCheck
+IF TRUE
+DO waitFor("timeout", 60 * 1000),
+ throw Exception("failed with timeout")
+ENDRULE
+
+##############################################################################
+# when triggerTimeoutCancel is called we need to call signalThrow to cause
+# a runtime exception in the main thread.
+
+RULE triggerTimeoutCancel
+CLASS TestWaitAfterSignalWakeMustMeet
+METHOD triggerTimeoutCancel
+IF TRUE
+DO signalThrow("timeout")
+ENDRULE
+
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/misc)
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/TestRecursiveTriggers.txt
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/misc/TestRecursiveTriggers.txt 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/TestRecursiveTriggers.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,78 +0,0 @@
-##############################################################################
-# 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
-#
-
-##############################################################################
-#
-# log a message to indicate that triggerMethod1 was called and fired the rule
-
-RULE log potentially recursively triggered method
-CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
-METHOD triggerMethod1(int)
-HELPER org.jboss.byteman.tests.helpers.Default
-AT ENTRY
-BIND test = $0,
- count = $1
-IF TRUE
-DO test.log("triggerMethod1 : triggered with " + count)
-ENDRULE
-
-##############################################################################
-#
-# log a message to indicate that triggerMethod2 was called and call
-# triggerMethod1 with recursive triggering enabled (the default)
-
-RULE test recursive trigger enabled
-CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
-METHOD triggerMethod2()
-HELPER org.jboss.byteman.tests.helpers.Default
-AT ENTRY
-BIND test : TestRecursiveTriggers = $0
-IF TRUE
-DO test.log("triggerMethod2 : triggered"),
- test.triggerMethod1(2)
-ENDRULE
-
-##############################################################################
-#
-# log a message to indicate that triggerMethod2 was called and call
-# triggerMethod1 with recursive triggering disabled and then again with
-# triggering enabled
-
-
-RULE test recursive trigger disabled then enabled
-CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
-METHOD triggerMethod3()
-HELPER org.jboss.byteman.tests.helpers.Default
-AT ENTRY
-BIND test : TestRecursiveTriggers = $0
-IF TRUE
-DO test.log("triggerMethod3 : triggered"),
- setTriggering(false),
- test.triggerMethod1(3),
- setTriggering(true),
- test.triggerMethod1(4)
-ENDRULE
-
-
-
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/TestRecursiveTriggers.txt (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/tests/dd/scripts/misc/TestRecursiveTriggers.txt)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/TestRecursiveTriggers.txt (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/dd/scripts/misc/TestRecursiveTriggers.txt 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,78 @@
+##############################################################################
+# 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
+#
+
+##############################################################################
+#
+# log a message to indicate that triggerMethod1 was called and fired the rule
+
+RULE log potentially recursively triggered method
+CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
+METHOD triggerMethod1(int)
+HELPER org.jboss.byteman.tests.helpers.Default
+AT ENTRY
+BIND test = $0,
+ count = $1
+IF TRUE
+DO test.log("triggerMethod1 : triggered with " + count)
+ENDRULE
+
+##############################################################################
+#
+# log a message to indicate that triggerMethod2 was called and call
+# triggerMethod1 with recursive triggering enabled (the default)
+
+RULE test recursive trigger enabled
+CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
+METHOD triggerMethod2()
+HELPER org.jboss.byteman.tests.helpers.Default
+AT ENTRY
+BIND test : TestRecursiveTriggers = $0
+IF TRUE
+DO test.log("triggerMethod2 : triggered"),
+ test.triggerMethod1(2)
+ENDRULE
+
+##############################################################################
+#
+# log a message to indicate that triggerMethod2 was called and call
+# triggerMethod1 with recursive triggering disabled and then again with
+# triggering enabled
+
+
+RULE test recursive trigger disabled then enabled
+CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
+METHOD triggerMethod3()
+HELPER org.jboss.byteman.tests.helpers.Default
+AT ENTRY
+BIND test : TestRecursiveTriggers = $0
+IF TRUE
+DO test.log("triggerMethod3 : triggered"),
+ setTriggering(false),
+ test.triggerMethod1(3),
+ setTriggering(true),
+ test.triggerMethod1(4)
+ENDRULE
+
+
+
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestEnclosedSynchronizationPropagation.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestEnclosedSynchronizationPropagation.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestEnclosedSynchronizationPropagation.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,3 +1,26 @@
+/*
+* 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 junit.framework.TestCase;
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestWaitAfterSignalWakeMustMeet.java (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/bugfixes/TestWaitAfterSignalWakeMustMeet.java)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestWaitAfterSignalWakeMustMeet.java (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/bugfixes/TestWaitAfterSignalWakeMustMeet.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,121 @@
+package org.jboss.byteman.tests.bugfixes;
+
+import org.jboss.byteman.tests.Test;
+import org.jboss.byteman.rule.exception.ExecuteException;
+
+/**
+ * This test accompaniesBYTEMAN-38. The bug happens when the same key is used for two successive pairs of
+ * calls to builtin helper methods waitFor(key) and signalWake(key, true). When the first call to waitFor
+ * happens before the first call to signalWake then the cleanup under signalWake fails to remove the
+ * Waiter object associated with key. The next call to waitFor finds a waiter which has been signalled
+ * and returns immediately. The call to signalWake shoudl remove the waiter before returning.
+ */
+public class TestWaitAfterSignalWakeMustMeet extends Test
+{
+ public TestWaitAfterSignalWakeMustMeet() {
+ super(TestWaitAfterSignalWakeMustMeet.class.getCanonicalName());
+ }
+
+ public void test() throws Exception
+ {
+ Thread thread1 = new Thread() {
+ public void run()
+ {
+ runThread1();
+ }
+ };
+ Thread thread2 = new Thread() {
+ public void run()
+ {
+ runThread2();
+ }
+ };
+ thread1.start();
+ thread2.start();
+ try {
+ triggerTimeoutCheck();
+ } catch (ExecuteException e) {
+ log("caught execute exception");
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ checkOutput();
+ }
+
+ public void ensureSignalWake()
+ {
+ // do nothing. this is just for the purpose of triggering
+ }
+
+ public void ensureWaitFor()
+ {
+ // do nothing. this is just for the purpose of triggering
+ }
+
+ public void triggerWaitFor()
+ {
+ // do nothing. this is just for the purpose of triggering
+ }
+
+ public void triggerRendezvous()
+ {
+ // do nothing. this is just for the purpose of triggering
+ }
+
+ public void triggerSignalWake()
+ {
+ // do nothing. this is just for the purpose of triggering
+ }
+
+ public void triggerTimeoutCheck() throws Exception
+ {
+ // do nothing. this is just for the purpose of triggering
+ }
+
+ public void triggerTimeoutCancel()
+ {
+ // do nothing. this is just for the purpose of triggering
+ }
+
+ public void runThread1()
+ {
+ ensureSignalWake();
+ //System.out.println("thread1 : ensured signalWake sent");
+ triggerWaitFor();
+ //System.out.println("thread1 : triggered waitFor");
+ triggerRendezvous();
+ //System.out.println("thread1 : triggered rendezvous 1");
+ triggerWaitFor();
+ //System.out.println("thread1 : triggered waitFor");
+ triggerRendezvous();
+ //System.out.println("thread1 : triggered rendezvous 2");
+ }
+
+ public void runThread2()
+ {
+ triggerSignalWake();
+ //System.out.println("thread2 : triggered signalWake");
+ ensureWaitFor();
+ //System.out.println("thread2 : ensured waitFor");
+ triggerRendezvous();
+ //System.out.println("thread2 : triggered rendezvous 1");
+ ensureWaitFor();
+ //System.out.println("thread2 : ensured waitFor");
+ triggerSignalWake();
+ //System.out.println("thread2 : triggered signalWake");
+ triggerRendezvous();
+ //System.out.println("thread2 : triggered rendezvous 2");
+ triggerTimeoutCancel();
+ //System.out.println("thread2 : cancelled timeout");
+ }
+
+ @Override
+ public String getExpected() {
+ logExpected("signalWake");
+ logExpected("waitFor");
+ logExpected("waitFor");
+ logExpected("signalWake");
+ logExpected("caught execute exception");
+ return super.getExpected();
+ }
+}
Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/Default.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/Default.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/Default.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -24,12 +24,19 @@
package org.jboss.byteman.tests.helpers;
import org.jboss.byteman.tests.Test;
+import org.jboss.byteman.rule.helper.Helper;
+import org.jboss.byteman.rule.Rule;
/**
* default helper used in byteman unit tests providing simple logging capability
*/
-public class Default
+public class Default extends Helper
{
+ public Default(Rule rule)
+ {
+ super(rule);
+ }
+
public void log(String message)
{
System.out.println(message);
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/TestWaitAfterSignalWakeMustMeetHelper.java (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/helpers/TestWaitAfterSignalWakeMustMeetHelper.java)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/TestWaitAfterSignalWakeMustMeetHelper.java (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/helpers/TestWaitAfterSignalWakeMustMeetHelper.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,87 @@
+package org.jboss.byteman.tests.helpers;
+
+import org.jboss.byteman.rule.helper.Helper;
+import org.jboss.byteman.rule.Rule;
+
+/**
+ */
+public class TestWaitAfterSignalWakeMustMeetHelper extends Helper
+{
+ protected TestWaitAfterSignalWakeMustMeetHelper(Rule rule) {
+ super(rule);
+ }
+
+ static boolean waitForCalled = false;
+ static boolean signalWakeCalled = false;
+ static Object lock = new Object();
+
+ public void waitFor(Object identifier, long timeout)
+ {
+ setWaitFor(); // there is a window here! we use a delay to close it
+ super.waitFor(identifier, timeout);
+ }
+
+ public boolean signalWake(Object identifier, boolean mustMeet)
+ {
+ setSignalWake(); // there is a window here! we use a delay to close it
+ return super.signalWake(identifier, mustMeet);
+ }
+
+ private void setWaitFor()
+ {
+ synchronized (lock) {
+ waitForCalled = true;
+ //System.out.println("waitForCalled <= true");
+ lock.notify();
+ }
+ }
+
+ private void setSignalWake()
+ {
+ synchronized (lock) {
+ signalWakeCalled = true;
+ //System.out.println("signalWakeCalled <= true");
+ lock.notify();
+ }
+ }
+
+ public void ensureWaitFor()
+ {
+ synchronized (lock) {
+ //System.out.println("*waitForCalled = " + waitForCalled);
+ while (!waitForCalled) {
+ try {
+ lock.wait();
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ //System.out.println("**waitForCalled = " + waitForCalled);
+ }
+ //System.out.println("***waitForCalled = " + waitForCalled);
+ waitForCalled = false;
+ //System.out.println("****waitForCalled = " + waitForCalled);
+ }
+ // close the window -- maybe leaves a little air gap
+ delay(1000);
+ }
+
+ public void ensureSignalWake()
+ {
+ synchronized (lock) {
+ //System.out.println("*signalWakeCalled = " + signalWakeCalled);
+ while (!signalWakeCalled) {
+ try {
+ lock.wait();
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ //System.out.println("**signalWakeCalled = " + signalWakeCalled);
+ }
+ //System.out.println("***signalWakeCalled = " + signalWakeCalled);
+ signalWakeCalled = false;
+ //System.out.println("****signalWakeCalled = " + signalWakeCalled);
+ }
+ // close the window -- maybe leaves a little air gap
+ delay(1000);
+ }
+}
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/misc)
Deleted: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java 2009-10-20 15:34:42 UTC (rev 29697)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -1,109 +0,0 @@
-/*
-* 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.misc;
-
-import org.jboss.byteman.tests.Test;
-
-/**
- * Test to ensure arithmetic operations compute as expected
- */
-public class TestRecursiveTriggers extends Test
-{
- public TestRecursiveTriggers()
- {
- super(TestRecursiveTriggers.class.getCanonicalName());
- }
-
- public void test()
- {
- try {
- log("calling TestRecursiveTriggers.triggerMethod1(1)");
- triggerMethod1(1);
- log("called TestRecursiveTriggers.triggerMethod1(1)");
-
- log("calling TestRecursiveTriggers.triggerMethod2()");
- triggerMethod2();
- log("called TestRecursiveTriggers.triggerMethod2()");
-
- log("calling TestRecursiveTriggers.triggerMethod3()");
- triggerMethod3();
- log("called TestRecursiveTriggers.triggerMethod3()");
-
- log("calling TestRecursiveTriggers.triggerMethod2()");
- triggerMethod2();
- log("called TestRecursiveTriggers.triggerMethod2()");
- } catch (Exception e) {
- log(e);
- }
-
- checkOutput(true);
- }
-
- public void triggerMethod1(int i)
- {
- log("inside TestRecursiveTriggers.triggerMethod1(" + i + ")");
- }
-
- public void triggerMethod2()
- {
- log("inside TestRecursiveTriggers.triggerMethod2()");
- }
-
- public void triggerMethod3()
- {
- log("inside TestRecursiveTriggers.triggerMethod3()");
- }
-
- @Override
- public String getExpected() {
- logExpected("calling TestRecursiveTriggers.triggerMethod1(1)");
- logExpected("triggerMethod1 : triggered with 1");
- logExpected("inside TestRecursiveTriggers.triggerMethod1(1)");
- logExpected("called TestRecursiveTriggers.triggerMethod1(1)");
-
- logExpected("calling TestRecursiveTriggers.triggerMethod2()");
- logExpected("triggerMethod2 : triggered");
- logExpected("triggerMethod1 : triggered with 2");
- logExpected("inside TestRecursiveTriggers.triggerMethod1(2)");
- logExpected("inside TestRecursiveTriggers.triggerMethod2()");
- logExpected("called TestRecursiveTriggers.triggerMethod2()");
-
- logExpected("calling TestRecursiveTriggers.triggerMethod3()");
- logExpected("triggerMethod3 : triggered");
- logExpected("inside TestRecursiveTriggers.triggerMethod1(3)");
- logExpected("triggerMethod1 : triggered with 4");
- logExpected("inside TestRecursiveTriggers.triggerMethod1(4)");
- logExpected("inside TestRecursiveTriggers.triggerMethod3()");
- logExpected("called TestRecursiveTriggers.triggerMethod3()");
-
- logExpected("calling TestRecursiveTriggers.triggerMethod2()");
- logExpected("triggerMethod2 : triggered");
- logExpected("triggerMethod1 : triggered with 2");
- logExpected("inside TestRecursiveTriggers.triggerMethod1(2)");
- logExpected("inside TestRecursiveTriggers.triggerMethod2()");
- logExpected("called TestRecursiveTriggers.triggerMethod2()");
-
- return super.getExpected();
- }
-}
\ No newline at end of file
Copied: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java (from rev 29697, labs/jbosstm/workspace/adinn/byteman/trunk/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_1/tests/src/org/jboss/byteman/tests/misc/TestRecursiveTriggers.java 2009-10-20 15:47:20 UTC (rev 29698)
@@ -0,0 +1,109 @@
+/*
+* 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.misc;
+
+import org.jboss.byteman.tests.Test;
+
+/**
+ * Test to ensure arithmetic operations compute as expected
+ */
+public class TestRecursiveTriggers extends Test
+{
+ public TestRecursiveTriggers()
+ {
+ super(TestRecursiveTriggers.class.getCanonicalName());
+ }
+
+ public void test()
+ {
+ try {
+ log("calling TestRecursiveTriggers.triggerMethod1(1)");
+ triggerMethod1(1);
+ log("called TestRecursiveTriggers.triggerMethod1(1)");
+
+ log("calling TestRecursiveTriggers.triggerMethod2()");
+ triggerMethod2();
+ log("called TestRecursiveTriggers.triggerMethod2()");
+
+ log("calling TestRecursiveTriggers.triggerMethod3()");
+ triggerMethod3();
+ log("called TestRecursiveTriggers.triggerMethod3()");
+
+ log("calling TestRecursiveTriggers.triggerMethod2()");
+ triggerMethod2();
+ log("called TestRecursiveTriggers.triggerMethod2()");
+ } catch (Exception e) {
+ log(e);
+ }
+
+ checkOutput(true);
+ }
+
+ public void triggerMethod1(int i)
+ {
+ log("inside TestRecursiveTriggers.triggerMethod1(" + i + ")");
+ }
+
+ public void triggerMethod2()
+ {
+ log("inside TestRecursiveTriggers.triggerMethod2()");
+ }
+
+ public void triggerMethod3()
+ {
+ log("inside TestRecursiveTriggers.triggerMethod3()");
+ }
+
+ @Override
+ public String getExpected() {
+ logExpected("calling TestRecursiveTriggers.triggerMethod1(1)");
+ logExpected("triggerMethod1 : triggered with 1");
+ logExpected("inside TestRecursiveTriggers.triggerMethod1(1)");
+ logExpected("called TestRecursiveTriggers.triggerMethod1(1)");
+
+ logExpected("calling TestRecursiveTriggers.triggerMethod2()");
+ logExpected("triggerMethod2 : triggered");
+ logExpected("triggerMethod1 : triggered with 2");
+ logExpected("inside TestRecursiveTriggers.triggerMethod1(2)");
+ logExpected("inside TestRecursiveTriggers.triggerMethod2()");
+ logExpected("called TestRecursiveTriggers.triggerMethod2()");
+
+ logExpected("calling TestRecursiveTriggers.triggerMethod3()");
+ logExpected("triggerMethod3 : triggered");
+ logExpected("inside TestRecursiveTriggers.triggerMethod1(3)");
+ logExpected("triggerMethod1 : triggered with 4");
+ logExpected("inside TestRecursiveTriggers.triggerMethod1(4)");
+ logExpected("inside TestRecursiveTriggers.triggerMethod3()");
+ logExpected("called TestRecursiveTriggers.triggerMethod3()");
+
+ logExpected("calling TestRecursiveTriggers.triggerMethod2()");
+ logExpected("triggerMethod2 : triggered");
+ logExpected("triggerMethod1 : triggered with 2");
+ logExpected("inside TestRecursiveTriggers.triggerMethod1(2)");
+ logExpected("inside TestRecursiveTriggers.triggerMethod2()");
+ logExpected("called TestRecursiveTriggers.triggerMethod2()");
+
+ return super.getExpected();
+ }
+}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list