diff --git a/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java b/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java index fad1d47fe..1349bbcb7 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/klass100/GetStaticCommand.java @@ -40,7 +40,8 @@ import static com.taobao.text.ui.Element.label; @Name("getstatic") @Summary("Show the static field of a class") -@Description(Constants.EXAMPLE + " getstatic -c 39eb305e org.apache.log4j.LogManager DEFAULT_CONFIGURATION_FILE\n" +@Description(Constants.EXAMPLE + " getstatic getstatic demo.MathGame random\n" + + " getstatic -c 39eb305e org.apache.log4j.LogManager DEFAULT_CONFIGURATION_FILE\n" + Constants.WIKI + Constants.WIKI_HOME + "getstatic") public class GetStaticCommand extends AnnotatedCommand { diff --git a/site/src/site/sphinx/en/getstatic.md b/site/src/site/sphinx/en/getstatic.md index f784f9169..be3a430f4 100644 --- a/site/src/site/sphinx/en/getstatic.md +++ b/site/src/site/sphinx/en/getstatic.md @@ -1,9 +1,38 @@ getstatic ========= +* It is recommended to use the [OGNL] (ognl.md) command, which will be more flexibility. + Check the static fields of classes conveniently, the usage is `getstatic class_name field_name`. -Tip: if the static field is a complex class, you can even use [`OGNL`](https://en.wikipedia.org/wiki/OGNL) to traverse, filter and access the inner properties of this class. +```bash +$ getstatic demo.MathGame random +field: random +@Random[ + serialVersionUID=@Long[3905348978240129619], + seed=@AtomicLong[120955813885284], + multiplier=@Long[25214903917], + addend=@Long[11], + mask=@Long[281474976710655], + DOUBLE_UNIT=@Double[1.1102230246251565E-16], + BadBound=@String[bound must be positive], + BadRange=@String[bound must be greater than origin], + BadSize=@String[size must be non-negative], + seedUniquifier=@AtomicLong[-3282039941672302964], + nextNextGaussian=@Double[0.0], + haveNextNextGaussian=@Boolean[false], + serialPersistentFields=@ObjectStreamField[][isEmpty=false;size=3], + unsafe=@Unsafe[sun.misc.Unsafe@2eaa1027], + seedOffset=@Long[24], +] +``` + + +Tip: if the static field is a complex class, you can even use [`OGNL`](https://commons.apache.org/proper/commons-ognl/language-guide.html) to traverse, filter and access the inner properties of this class. + +* [OGNL official guide](https://commons.apache.org/proper/commons-ognl/language-guide.html) +* [Special usages](https://github.com/alibaba/arthas/issues/71) + E.g. suppose `n` is a `Map` and its key is a `Enum`, then you can achieve this if you want to pick the key with a specific `Enum` value: diff --git a/site/src/site/sphinx/en/watch.md b/site/src/site/sphinx/en/watch.md index 97150a34c..d6652863f 100644 --- a/site/src/site/sphinx/en/watch.md +++ b/site/src/site/sphinx/en/watch.md @@ -3,7 +3,7 @@ watch Monitor methods in data aspect including `return values`, `exceptions` and `parameters`. -With the help of [OGNL](https://en.wikipedia.org/wiki/OGNL), you can easily check the details of variables when methods being invoked. +With the help of [OGNL](https://commons.apache.org/proper/commons-ognl/index.html), you can easily check the details of variables when methods being invoked. ### Parameters & Options diff --git a/site/src/site/sphinx/getstatic.md b/site/src/site/sphinx/getstatic.md index d9a9ef94a..69fabd78f 100644 --- a/site/src/site/sphinx/getstatic.md +++ b/site/src/site/sphinx/getstatic.md @@ -1,11 +1,39 @@ getstatic === +* 推荐直接使用[ognl](ognl.md)命令,更加灵活。 + 通过getstatic命令可以方便的查看类的静态属性。使用方法为`getstatic class_name field_name` +```bash +$ getstatic demo.MathGame random +field: random +@Random[ + serialVersionUID=@Long[3905348978240129619], + seed=@AtomicLong[120955813885284], + multiplier=@Long[25214903917], + addend=@Long[11], + mask=@Long[281474976710655], + DOUBLE_UNIT=@Double[1.1102230246251565E-16], + BadBound=@String[bound must be positive], + BadRange=@String[bound must be greater than origin], + BadSize=@String[size must be non-negative], + seedUniquifier=@AtomicLong[-3282039941672302964], + nextNextGaussian=@Double[0.0], + haveNextNextGaussian=@Boolean[false], + serialPersistentFields=@ObjectStreamField[][isEmpty=false;size=3], + unsafe=@Unsafe[sun.misc.Unsafe@2eaa1027], + seedOffset=@Long[24], +] +``` + 如果该静态属性是一个复杂对象,还可以支持在该属性上通过ognl表示进行遍历,过滤,访问对象的内部属性等操作。 +* OGNL特殊用法请参考:[https://github.com/alibaba/arthas/issues/71](https://github.com/alibaba/arthas/issues/71) +* OGNL表达式官方指南:[https://commons.apache.org/proper/commons-ognl/language-guide.html](https://commons.apache.org/proper/commons-ognl/language-guide.html) + + 例如,假设n是一个Map,Map的Key是一个Enum,我们想过滤出Map中Key为某个Enum的值,可以写如下命令 ```