首页   快速返回

arthas OGNL 使用     所属分类 arthas 浏览量 62
OGNL  Object Graph Navigation Language

ognl -x 2 '@Singleton@getInstance()'                                                                                             
ognl '@Demo@staticFiled'

ognl '@java.lang.System@out.println("hello ognl")'

ognl '@System@out.println("hello ognl")'


ognl @dyyx.util.WebUtil@LOG
Failed to execute ognl, exception message: ognl.OgnlException: Could not get static field LOG from class dyyx.util.WebUtil [java.lang.ClassNotFoundException: Unable to resolve class: dyyx.util.WebUtil], please check $HOME/logs/arthas/arthas.log for more details. 
[arthas@11593]$ ognl @dyyx.util.WebUtil@echoSize
Failed to execute ognl, exception message: ognl.OgnlException: Could not get static field echoSize from class dyyx.util.WebUtil [java.lang.ClassNotFoundException: Unable to resolve class: dyyx.util.WebUtil], please check $HOME/logs/arthas/arthas.log for more details. 

需要指定 classloader 

ClassLoader 的 hashcode,默认值 SystemClassLoader

WebUtil  由  tomcat webapp 加载

sc -d dyyx.util.WebUtil
class-loader      +-ParallelWebappClassLoader                                                                                      
                       context: ROOT                                                                                                
                       delegate: false                                                                                              
                     ----------> Parent Classloader:                                                                                
                     java.net.URLClassLoader@548c4f57                                                                               
                                                                                                                                    
                     +-java.net.URLClassLoader@548c4f57                                                                             
                       +-sun.misc.Launcher$AppClassLoader@42a57993                                                                  
                         +-sun.misc.Launcher$ExtClassLoader@15975490                                                                
 classLoaderHash   df8a059   
 
ognl -c df8a059  @dyyx.util.WebUtil@LOG
@Logger[
    FQCN=@String[org.apache.log4j.Logger],
    class$org$apache$log4j$Logger=@Class[class org.apache.log4j.Logger],
]

[arthas@11593]$ ognl -c df8a059  @dyyx.util.WebUtil@LOG -x 2
@Logger[
    FQCN=@String[org.apache.log4j.Logger],
    class$org$apache$log4j$Logger=@Class[
        ANNOTATION=@Integer[8192],
        ENUM=@Integer[16384],
        SYNTHETIC=@Integer[4096],
        cachedConstructor=null,
        newInstanceCallerCache=null,
        name=@String[org.apache.log4j.Logger],
        allPermDomain=@ProtectionDomain[ProtectionDomain  null
 null
 
 java.security.Permissions@7bfd6923 (
 ("java.security.AllPermission" "" "")
)

],
        useCaches=@Boolean[true],
        reflectionData=@SoftReference[java.lang.ref.SoftReference@23d121a0],
        classRedefinedCount=@Integer[0],
        genericInfo=null,
        serialVersionUID=@Long[3206093459760846163],
        serialPersistentFields=@ObjectStreamField[][isEmpty=true;size=0],
        reflectionFactory=@ReflectionFactory[sun.reflect.ReflectionFactory@62c77f23],
        initted=@Boolean[true],
        enumConstants=null,
        enumConstantDirectory=null,
        annotationData=null,
        annotationType=null,
        classValueMap=null,
    ],
]
[arthas@11593]$ 


执行多行表达式,赋值给临时变量,返回List

ognl '#value1=@System@getProperty("java.home"), #value2=@System@getProperty("user.name"), {#value1, #value2}'

@ArrayList[
    @String[/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre],
    @String[dugang],
]

上一篇     下一篇
编程心法

arthas watch 使用

arthas tt 使用

zookeeper内部原理

httpclient post 请求返回400

使用jmx监控jvm