Mark Lee wrote:
1) Is it possible monitoring body of run() method, only using byteman, without System.out.println() statement?
In particular, consider the fact that the ThrTest class is a derived class of java.lang.Thread class.
Yes, it is possible and it makes no difference that ThrTest is a derived class.
2) why does not work below my byteman script?
You have an error in your rule:
BIND msg = "*at Entry ival = " + ival;
After the "+" operator you are trying to refer to a field of the target instance for the call to ThrTest.run(). However, the parser thinks that ival is a reference to a (rule local) BIND variable . You need to specify the field access as a field access to a specific object:
BIND msg = "*at Entry ival = " + $0.ival;
If you have compiled the code with -g you could also write
BIND msg = "*at Entry ival = " + $this.ival;
I suggest you use the offline type checker bmcheck.sh located in the bin directory of the Byteman download to check your rules before running them. Details of how to run bmcheck are in the Programmer's Guide. Alternatively, if you are running with maven/BMUnit to run Byteman tests then you can use the maven rule checker plugin to automatically run bmcheck on your rules before your tests get run. The latest Programmer's Guide and the rulecheck plugin tutorial can be accessed via links located on the Byteman Documentation page