import{_ as c,o,c as d,a as e,b as a,w as t,e as s,d as r,r as l}from"./app.6c27e557.js";const u={},p=e("h1",{id:"dump",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#dump","aria-hidden":"true"},"#"),s(" dump")],-1),h={href:"https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-dump",target:"_blank",rel:"noopener noreferrer"},m=e("code",null,"dump",-1),v=s(" online tutorial"),b=e("div",{class:"custom-container tip"},[e("p",{class:"custom-container-title"},"TIP"),e("p",null,"Dump the bytecode for the particular classes to the specified directory.")],-1),g=s("The dump command is used to dump the bytecode of classes actually running in the JVM to a specified directory. It is suitable for bulk downloading the bytecode of classes in a specific package directory. If you need to decompile a single class or view class information in real-time, you can refer to "),_=s("jad"),f=s("."),k=e("h2",{id:"options",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#options","aria-hidden":"true"},"#"),s(" Options")],-1),L=e("thead",null,[e("tr",null,[e("th",{style:{"text-align":"right"}},"Name"),e("th",{style:{"text-align":"left"}},"Specification")])],-1),y=e("tr",null,[e("td",{style:{"text-align":"right"}},[e("em",null,"class-pattern")]),e("td",{style:{"text-align":"left"}},"class name pattern")],-1),x=e("td",{style:{"text-align":"right"}},[e("code",null,"[c:]")],-1),C={style:{"text-align":"left"}},A=s("hashcode of the "),S=s("class loader"),w=s(" that loaded the target class"),O=e("tr",null,[e("td",{style:{"text-align":"right"}},[e("code",null,"[classLoaderClass:]")]),e("td",{style:{"text-align":"left"}},"The class name of the ClassLoader that executes the expression.")],-1),E=e("tr",null,[e("td",{style:{"text-align":"right"}},[e("code",null,"[d:]")]),e("td",{style:{"text-align":"left"}},"set the destination directory for class files")],-1),$=e("tr",null,[e("td",{style:{"text-align":"right"}},[e("code",null,"[E]")]),e("td",{style:{"text-align":"left"}},"turn on regex match, the default behavior is wild card match")],-1),j=r(`
$ dump java.lang.String
HASHCODE CLASSLOADER LOCATION
null /Users/admin/logs/arthas/classdump/java/lang/String.class
Affect(row-cnt:1) cost in 119 ms.
$ dump demo.*
HASHCODE CLASSLOADER LOCATION
3d4eac69 +-sun.misc.Launcher$AppClassLoader@3d4eac69 /Users/admin/logs/arthas/classdump/sun.misc.Launcher$AppClassLoader-3d4eac69/demo/MathGame.class
+-sun.misc.Launcher$ExtClassLoader@66350f69
Affect(row-cnt:1) cost in 39 ms.
$ dump -d /tmp/output java.lang.String
HASHCODE CLASSLOADER LOCATION
null /tmp/output/java/lang/String.class
Affect(row-cnt:1) cost in 138 ms.
Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader.
if you use-c
, you have to manually type hashcode by -c <hashcode>
.
$ dump -c 3d4eac69 demo.*
For classloader with only one instance, it can be specified by --classLoaderClass
using class name, which is more convenient to use.
$ dump --classLoaderClass sun.misc.Launcher$AppClassLoader demo.*
HASHCODE CLASSLOADER LOCATION
3d4eac69 +-sun.misc.Launcher$AppClassLoader@3d4eac69 /Users/admin/logs/arthas/classdump/sun.misc.Launcher$AppClassLoader-3d4eac69/demo/MathGame.class
+-sun.misc.Launcher$ExtClassLoader@66350f69
Affect(row-cnt:1) cost in 39 ms.
The value of --classloaderclass
is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, -c <hashcode>
is dynamic.