5 Replies Latest reply on Oct 19, 2012 10:36 AM by adinn

    problem using AFTER WRITE on local variable

    msulliv1

      I'm having trouble using AFTER WRITE on a local variable.

       

      Here's a snippet of my class (see attached).

       

      public class Foo {

         ...

              public  void bar(int i, String myText) {

                      String current="hi there";

                      System.out.println(i+ " ... " + current);

              }

       

      My rule is:

      RULE test debug

      CLASS Foo

      METHOD bar

      #AT ENTRY

      AFTER WRITE $current

      IF true

      DO traceln("byteman is here");

      ENDRULE

       

      bmcheck fails to parse the rule:

      $ /u01/app/home/asmsadm/mike/byteman_home/byteman-2.1.0/bin/bmcheck.sh -cp . myrule.txt
      checking rule test debug
      TestScript : Error transforming class Foo using  rule "test debug" loaded from myrule.txt line 6

      java.lang.Error: Failed to transform class Foo using rule test debug

      TestScript: 1 total errors
                  0 parse errors
                  0 type errors

      Thanks,

      Mike

        • 1. Re: problem using AFTER WRITE on local variable
          adinn

          Hi Mike,

           

          I am a little puzzled by the output you are seeing. I just ran bmcheck and got this output

           

          [adinn@sputstik byteman]$ bmcheck -cp . foo.btm

          checking rule test debug against class Foo

          parsed rule "test debug" for class Foo

          type checked rule "test debug"

           

          TestScript: no errors

           

          I used this class definition

           

          [adinn@sputstik byteman]$ cat Foo.java

          public class Foo {

              public static void main(String[] args)

              {

              Foo foo = new Foo();

           

              foo.bar(1, "hello");

              }

           

              public  void bar(int i, String myText) {

              String current="hi there";

              System.out.println(i+ " ... " + current);

              }

          }

           

          and when I run it I get this

           

          [adinn@sputstik byteman]$ bmjava -l foo.btm Foo

          byteman is here

          1 ... hi there

           

          How did you compile your code? You should use command

           

          javac -g Foo.java

           

          Also, which java JDK are you using?

          • 2. Re: problem using AFTER WRITE on local variable
            msulliv1

            Andrew,

            Ah! I should have known. You are correct I was missing '-g' option to java compile. Once I did that I got the expected output. Thanks for you help.

            Mike

            • 3. Re: problem using AFTER WRITE on local variable
              adinn

              Hi Mike

              Mike Sullivan wrote:

               

              Ah! I should have known. You are correct I was missing '-g' option to java compile. Once I did that I got the expected output. Thanks for you help.

              No problem. Let me know how you get on with using Byteman. Please report any things you like or dislike and would like to see improved. Also, f you can, please publish details of your use cases so others can see how it has helped you.

               

              regards,

               

               

              ndrew Dinn

              • 4. Re: problem using AFTER WRITE on local variable
                msulliv1

                Andrew,

                Here was my most useful use case so far, causing a failure in 2-phase commit to verify integration of Websphere MQ and JBoss EAP works: https://community.jboss.org/wiki/UsingJBossWithWebsphereMQSettingUpAXARecoveryModule. Where would I place these use cases?

                 

                Mike

                • 5. Re: problem using AFTER WRITE on local variable
                  adinn

                  Hi Mike,

                  Mike Sullivan wrote:

                   

                  Here was my most useful use case so far, causing a failure in 2-phase commit to verify integration of Websphere MQ and JBoss EAP works: https://community.jboss.org/wiki/UsingJBossWithWebsphereMQSettingUpAXARecoveryModule. Where would I place these use cases?

                   

                  Wow, that's a great article. Thanks very much for publishing it.

                   

                  Your link is all that is needed to provide other Byteman users with an example of how to use Byteman to easily set up the test scenario. It would be hard to find a simpler or quicker way to implement this scenario where you are able both to exercise real code but also break execution at a highly specific point and ensure recovery kicks in. Thanks again.

                   

                  regards,

                   

                   

                  Andrew Dinn