1 Reply Latest reply on Apr 16, 2010 7:41 AM by adinn

    $this instead of $0 - applicable with bytemancheck.sh?

    jaikiran

      The Byteman documentation says:

       

      The trigger method recipient and parameters may be referred to by index using the symbols $0 (invalid for a static method), $1 etc. If the method has been compiled with the relevant debug options then symbolic references may also be used. So, for example, $this may be used as an alias for $0 and $myArg may be used as an alias for $1 if the method first parameter is declared with name myArg

      I have this rule:

       

      RULE Thread_Exit
      CLASS java.lang.Thread
      METHOD exit
      AT ENTRY
      IF  TRUE
      
      DO 
      System.out.println("Exit of thread " + $0)
      ENDRULE
      

       

      which when tested using bytemancheck.sh comes out clean without any errors. However, when I change $0 to $this:

       

      RULE Thread_Exit
      CLASS java.lang.Thread
      METHOD exit
      AT ENTRY
      IF  TRUE
      
      DO 
      System.out.println("Exit of thread " + $this)
      ENDRULE
      

       

      bytemancheck.sh throws:

       

      TestScript : Error transforming class java.lang.Thread using  rule "Thread_Exit" loaded from /home/jaikiran/Desktop/testbyteman.txt line 5
      
      java.lang.Error: Failed to transform class java.lang.Thread using rule Thread_Exit
      
      TestScript: 1 total errors
                  0 parse errors
                  0 type errors
      

       

       

      Is this because, the original class was not compiled with debug info?

        • 1. Re: $this instead of $0 - applicable with bytemancheck.sh?
          adinn

          bytemancheck.sh throws:

           

          TestScript : Error transforming class java.lang.Thread using  rule "Thread_Exit" loaded from /home/jaikiran/Desktop/testbyteman.txt line 5

          java.lang.Error: Failed to transform class java.lang.Thread using rule Thread_Exit

          TestScript: 1 total errors
                      0 parse errors
                      0 type errors

           

           

          Is this because, the original class was not compiled with debug info?

           

          The original class being java.lang.Thread. Yes, I think this is probably the case. You can easily check this by dumping the version of Thread.class in your boot classpath:

           

          javap -c -private -verbose java.lang.Thread

          My Sun jdk 1.6.0_14 has line numbers for all methods but no local variable tables.