使用参考
watch demo.MathGame primeFactors "{params,returnObj}" -x 2
观察方法出参和返回值
watch demo.MathGame primeFactors "{params,returnObj}" -x 2 -b
观察方法入参
watch demo.MathGame primeFactors "{params,target,returnObj}" -x 2 -b -s -n 2
同时观察方法调用前和方法返回后
watch demo.MathGame primeFactors "{params,target}" -x 3
调整-x的值,观察具体的方法参数值
watch demo.MathGame primeFactors "{params[0],target}" "params[0]<0"
条件表达式的例子
watch demo.MathGame primeFactors "{params[0],throwExp}" -e -x 2
观察异常信息的例子
watch demo.MathGame primeFactors '{params, returnObj}' '#cost>200' -x 2
按照耗时进行过滤
watch demo.MathGame primeFactors 'target'
观察当前对象中的属性
watch demo.MathGame primeFactors 'target.illegalArgumentCount'
然后使用target.field_name访问当前对象的某个属性
watch demo.MathGame * '{params,@demo.MathGame@random.nextInt(100)}' -n 1 -x 2
获取类的静态字段、调用类的静态方法的例子
watch javax.servlet.Filter * --exclude-class-pattern com.demo.TestFilter
排除掉指定的类
不匹配子类
options disable-sub-class true
使用 -v 参数打印更多信息
watch -v -x 2 demo.MathGame print 'params' 'params[0] > 100000'