其他分享
首页 > 其他分享> > Arthas的class和classloader相关命令-sc/sm/jad/mc/redefine/dump/classloader

Arthas的class和classloader相关命令-sc/sm/jad/mc/redefine/dump/classloader

作者:互联网

1.sc:查看 JVM 已加载的类信息

sc com.lyb.web.mySpringBoot.demo.RedefineTestSimple
sc com.lyb.web.mySpringBoot.demo.RedefineTestSimple -d

 

 

 

2.sm:查看已加载类的方法信息

sm com.lyb.web.mySpringBoot.demo.RedefineTestSimple
sm com.lyb.web.mySpringBoot.demo.RedefineTestSimple -d

 

 

 

3.jad:反编译指定已加载类的源码

jad --source-only com.lyb.web.mySpringBoot.demo.RedefineTestSimple

保存源码到

/Users/liyabin/projectCode/test/RedefineTestSimple.java
jad --source-only com.lyb.web.mySpringBoot.demo.RedefineTestSimple > /Users/liyabin/projectCode/test/RedefineTestSimple.java

修改源码如下:添加一行日志

4.mc:Memory Compiler/内存编译器,编译.java文件生成.class

编译ThreadAppendData.java为字节码文件,存放到/Users/liyabin/projectCode/test目录下

mc /Users/liyabin/projectCode/test/RedefineTestSimple.java -d /Users/liyabin/projectCode/test

 

5.redefine:加载外部的.class文件,redefine jvm 已加载的类。

redefine /Users/liyabin/projectCode/test/com/lyb/web/mySpringBoot/demo/RedefineTestSimple.class

收到添加的代码生效:

恢复原始代码

redefine /Users/liyabin/projectCode/my-spring-boot/mySpringBoot-web/target/classes/com/lyb/web/mySpringBoot/demo/RedefineTestSimple.class 

6.dump:dump 已加载类的 bytecode 到特定目录

dump -d /Users/liyabin/projectCode/test com.lyb.web.mySpringBoot.demo.RedefineTestSimple 

 7.classloader:查看 classloader 的继承树,urls,类加载信息

classloader
classloader -l
classloader -c 1b68b9a4

 

标签:web,redefine,lyb,mySpringBoot,dump,demo,classloader,RedefineTestSimple,com
来源: https://www.cnblogs.com/fycn01/p/16583876.html