ognl

执行ognl表达式

命令选项 描述
-c, --classloader <hash> 指定ClassLoader的哈希值
--classLoaderClass <name> 指定ClassLoader的类名
-x, --expand <level> 指定扩展对象层级,默认1
-h, --help 帮助
<express> ognl表达式

示例

# 简单打印
[arthas@17028]$ ognl "{\"a\", 'b', 1, false}"
@ArrayList[
    @String[a],
    @Character[b],
    @Integer[1],
    @Boolean[false],
]

# 调用静态函数 attach的服务控制台会打印Hello World
[arthas@17028]$ ognl "@java.lang.System@out.println('Hello World!')"
null

# 获得静态常量
[arthas@17028]$ ognl "@java.lang.Math@PI"
@Double[3.141592653589793]
[arthas@17028]$ ognl "@java.lang.Math@E"
@Double[2.718281828459045]

# 执行多行表达式,赋值临时变量
[arthas@17028]$ ognl '#value1=@System@getProperty("java.home"), #value2=@System@getProperty("java.runtime.name"), {#value1, #value2}'
@ArrayList[
    @String[D:\tools\JDK8\jre],
    @String[Java(TM) SE Runtime Environment],
]