getstatic

通过getstatic命令可以方便的查看类的静态属性。

使用方法为getstatic class_name field_name,推荐直接使用ognl更加灵活。

命令选项 描述
-c, --classloader <hash> 指定ClassLoader实例的hash码
--classloaderClass <name> 指定ClassLoader的类
-x, --expand <level> 展开对象的层级,默认为1
-E, --regex 开启正则匹配,默认为通配符匹配
-h, --help 帮助
<class-pattern> 类名模式,使用.或/作为包分隔符
<field-pattern> 静态字段模式
<express> ognl表达式

示例

# 查看java.lang.Math的PI静态字段的值 字段为public
[arthas@21536]$ getstatic java.lang.Math PI
field: PI
@Double[3.141592653589793]
Affect(row-cnt:1) cost in 4 ms.

# 通配符匹配Math 使用OGNL计算PI
[arthas@21536]$ getstatic *.Math PI '#this + 1'
field: PI
@Double[4.141592653589793]
Affect(row-cnt:1) cost in 4 ms.

# 过滤System中properties中有java的属性
[arthas@21536]$ getstatic java.lang.System props 'entrySet().{? #this.value.contains("java")}'