Hi Den,
The verify error I got last time was a red herring. This morning I did manage successfully to load and unload my rule using JRockit 1.6.0_20-b02 (the reason I got the verify error before was because I was using JBoss AS7 and I did not configure the module loader to ensure that Byteman classes were visible to all loaders (you need to start AS7 with -Djboss.modules.system.pkgs=org.jboss.byteman). Here's what I did (n.b. I am starting jboss using my own private start script)
[adinn@localhost byteman]$ export JBOSS_OPTS="$JBOSS_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman"
[adinn@localhost byteman]$ jboss start -debug -watch
starting standalone AS7
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /home/adinn/jboss/jbossas/git/jboss-as/build/target/jboss-as-7.1.0.Alpha1-SNAPSHOT
JAVA: /home/adinn/Download/jrockit/jrmc-4.0.1-1.6.0/bin/java
JAVA_OPTS: -server -Xms600M -Xmx600M -XX:MaxPermSize=128m -Djboss.modules.system.pkgs=org.jboss.byteman -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
=========================================================================
[WARN ][jrockit] MaxPermSize=128m ignored: Not a valid option for JRockit
Listening for transport dt_socket at address: 5005
Listening for transport dt_socket at address: 5005
11:42:01,784 INFO [org.jboss.modules] JBoss Modules version 1.0.1.GA
11:42:02,033 INFO [org.jboss.msc] JBoss MSC version 1.0.0.GA
11:42:02,094 INFO [org.jboss.as] JBoss AS 7.1.0.Alpha1-SNAPSHOT "Lightning" starting
. . .
Ok, that's jboss started now I install the agent and then submit and unsubmit the rule
[adinn@localhost byteman]$ bminstall.sh -Dorg.jboss.byteman.verbose -Dorg.jboss.byteman.dump.generated.classes -Dorg.jboss.byteman.dump.generated.classes.directory=dump 6561
[adinn@localhost byteman]$ bmsubmit.sh foo.btm
install rule foo
[adinn@localhost byteman]$ bmsubmit.sh
# File foo.btm line 5
RULE foo
CLASS FileSystemDeploymentService
METHOD scan
AT ENTRY
IF TRUE
DO traceln("scan")
ENDRULE
Transformed in:
loader: ModuleClassLoader for Module "org.jboss.as.deployment-scanner:main" from local module loader @2cba5bdb (roots: /home/adinn/jboss/jbossas/git/jboss-as/build/target/jboss-as-7.1.0.Alpha1-SNAPSHOT/modules)
trigger method: org.jboss.as.server.deployment.scanner.FileSystemDeploymentService.scan() void
compiled successfully
[adinn@localhost byteman]$ bmsubmit.sh -u
uninstall RULE foo
[adinn@localhost byteman]$
During this install/load/unload I saw the following in the AS7 output
. . .
11:42:42,055 INFO [stdout] (Attach Listener) Setting org.jboss.byteman.verbose=
11:42:42,055 INFO [stdout] (Attach Listener) Setting org.jboss.byteman.dump.generated.classes=
11:42:42,055 INFO [stdout] (Attach Listener) Setting org.jboss.byteman.dump.generated.classes.directory=dump
11:42:42,083 INFO [stdout] (Attach Listener) TransformListener() : accepting requests on localhost:9091
11:42:45,740 INFO [stdout] (Thread-17) TransformListener() : handling connection on port 9091
11:42:45,777 INFO [stdout] (Thread-17) retransforming org.jboss.as.server.deployment.scanner.FileSystemDeploymentService
11:42:45,856 INFO [stdout] (Thread-17) org.jboss.byteman.agent.Transformer : possible trigger for rule foo in class org.jboss.as.server.deployment.scanner.FileSystemDeploymentService
11:42:45,902 INFO [stdout] (Thread-17) RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into org.jboss.as.server.deployment.scanner.FileSystemDeploymentService.scan() void for rule foo
11:42:45,940 INFO [stdout] (Thread-17) org.jboss.byteman.agent.Transformer : inserted trigger for foo in class org.jboss.as.server.deployment.scanner.FileSystemDeploymentService
11:42:45,960 INFO [stdout] (Thread-17) org.jboss.byteman.agent.Transformer : Saving transformed bytes to dump/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.class
11:42:48,807 INFO [stdout] (DeploymentScanner-threads - 2) Rule.execute called for foo_0
11:42:48,818 INFO [stdout] (DeploymentScanner-threads - 2) HelperManager.install for helper classorg.jboss.byteman.rule.helper.Helper
11:42:48,819 INFO [stdout] (DeploymentScanner-threads - 2) calling activated() for helper classorg.jboss.byteman.rule.helper.Helper
11:42:48,819 INFO [stdout] (DeploymentScanner-threads - 2) Default helper activated
11:42:48,819 INFO [stdout] (DeploymentScanner-threads - 2) calling installed(foo) for helper classorg.jboss.byteman.rule.helper.Helper
11:42:48,820 INFO [stdout] (DeploymentScanner-threads - 2) Installed rule using default helper : foo
11:42:48,821 INFO [stdout] (DeploymentScanner-threads - 2) foo execute
11:42:48,821 INFO [stdout] (DeploymentScanner-threads - 2) scan
11:42:53,834 INFO [stdout] (DeploymentScanner-threads - 2) Rule.execute called for foo_0
11:42:53,834 INFO [stdout] (DeploymentScanner-threads - 2) foo execute
11:42:53,835 INFO [stdout] (DeploymentScanner-threads - 2) scan
11:42:58,840 INFO [stdout] (DeploymentScanner-threads - 2) Rule.execute called for foo_0
11:42:58,841 INFO [stdout] (DeploymentScanner-threads - 2) foo execute
11:42:58,842 INFO [stdout] (DeploymentScanner-threads - 2) scan
11:43:03,852 INFO [stdout] (DeploymentScanner-threads - 1) Rule.execute called for foo_0
11:43:03,855 INFO [stdout] (DeploymentScanner-threads - 1) foo execute
11:43:03,858 INFO [stdout] (DeploymentScanner-threads - 1) scan
11:43:08,868 INFO [stdout] (DeploymentScanner-threads - 1) Rule.execute called for foo_0
11:43:08,869 INFO [stdout] (DeploymentScanner-threads - 1) foo execute
11:43:08,878 INFO [stdout] (DeploymentScanner-threads - 1) scan
11:43:10,315 INFO [stdout] (Thread-17) TransformListener() : handling connection on port 9091
11:43:13,896 INFO [stdout] (DeploymentScanner-threads - 2) Rule.execute called for foo_0
11:43:13,897 INFO [stdout] (DeploymentScanner-threads - 2) foo execute
11:43:13,898 INFO [stdout] (DeploymentScanner-threads - 2) scan
11:43:15,556 INFO [stdout] (Thread-17) TransformListener() : handling connection on port 9091
11:43:15,574 INFO [stdout] (Thread-17) retransforming org.jboss.as.server.deployment.scanner.FileSystemDeploymentService
11:43:15,595 INFO [stdout] (Thread-17) HelperManager.uninstall for helper classorg.jboss.byteman.rule.helper.Helper
11:43:15,596 INFO [stdout] (Thread-17) calling uninstalled(foo) for helper classorg.jboss.byteman.rule.helper.Helper
11:43:15,596 INFO [stdout] (Thread-17) Uninstalled rule using default helper : foo
11:43:15,596 INFO [stdout] (Thread-17) calling deactivated() for helper classorg.jboss.byteman.rule.helper.Helper
11:43:15,596 INFO [stdout] (Thread-17) Default helper deactivated
. . .
So, you can see the agent being installed, the code injected (and the bytecode eing dumped to a file) the rule firing and then the rule bieng uninstalled and the rule no longer firing. I decompiled the bytecode and it doesn't look like their is anythign wrong with it.
One thing that might be revealing would be for you start up the agent with your JRockit release using -javaagent on the command line and also setting the -D options I passsed to bminstall
-Dorg.jboss.byteman.verbose -Dorg.jboss.byteman.dump.generated.classes -Dorg.jboss.byteman.dump.generated.classes.directory=dump
You will need to create a directory called dump in the working directory of your program.
The verbose trace might at least show something about what is happening. Also, when the bytecode is transformed it will be dumped to a class file below directory dump. You can decompile this with javap -c to look at the bytecode and see what might be causing the verify error. I'd be happy to try to check it for you but, of course, I understand that you might not be able to share this code with me. Let me know what you can find out from trying this, also whether you can get Byteman to work on a different version of JRockit.