import{_ as l,o as i,c as u,a as s,b as a,w as p,e as n,d as o,r as t}from"./app.4d248835.js";const r={},k=s("h1",{id:"jad",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#jad","aria-hidden":"true"},"#"),n(" jad")],-1),d={href:"https://arthas.aliyun.com/3.x/doc/arthas-tutorials?language=cn&id=command-jad",target:"_blank",rel:"noopener noreferrer"},m=s("code",null,"jad",-1),v=n("\u5728\u7EBF\u6559\u7A0B"),b=s("div",{class:"custom-container tip"},[s("p",{class:"custom-container-title"},"\u63D0\u793A"),s("p",null,"\u53CD\u7F16\u8BD1\u6307\u5B9A\u5DF2\u52A0\u8F7D\u7C7B\u7684\u6E90\u7801")],-1),h=s("code",null,"jad",-1),g=n(" \u547D\u4EE4\u5C06 JVM \u4E2D\u5B9E\u9645\u8FD0\u884C\u7684 class \u7684 byte code \u53CD\u7F16\u8BD1\u6210 java \u4EE3\u7801\uFF0C\u4FBF\u4E8E\u4F60\u7406\u89E3\u4E1A\u52A1\u903B\u8F91\uFF1B\u5982\u9700\u6279\u91CF\u4E0B\u8F7D\u6307\u5B9A\u5305\u7684\u76EE\u5F55\u7684 class \u5B57\u8282\u7801\u53EF\u4EE5\u53C2\u8003 "),y=n("dump"),w=n("\u3002"),_=o(`
\u53C2\u6570\u540D\u79F0 | \u53C2\u6570\u8BF4\u660E |
---|---|
class-pattern | \u7C7B\u540D\u8868\u8FBE\u5F0F\u5339\u914D |
[c:] | \u7C7B\u6240\u5C5E ClassLoader \u7684 hashcode |
[classLoaderClass:] | \u6307\u5B9A\u6267\u884C\u8868\u8FBE\u5F0F\u7684 ClassLoader \u7684 class name |
[E] | \u5F00\u542F\u6B63\u5219\u8868\u8FBE\u5F0F\u5339\u914D\uFF0C\u9ED8\u8BA4\u4E3A\u901A\u914D\u7B26\u5339\u914D |
java.lang.String
$ jad java.lang.String
ClassLoader:
Location:
/*
* Decompiled with CFR.
*/
package java.lang;
import java.io.ObjectStreamField;
import java.io.Serializable;
...
public final class String
implements Serializable,
Comparable<String>,
CharSequence {
private final char[] value;
private int hash;
private static final long serialVersionUID = -6849794470754667710L;
private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];
public static final Comparator<String> CASE_INSENSITIVE_ORDER = new CaseInsensitiveComparator();
...
public String(byte[] byArray, int n, int n2, Charset charset) {
/*460*/ if (charset == null) {
throw new NullPointerException("charset");
}
/*462*/ String.checkBounds(byArray, n, n2);
/*463*/ this.value = StringCoding.decode(charset, byArray, n, n2);
}
...
$ jad --source-only demo.MathGame
/*
* Decompiled with CFR 0_132.
*/
package demo;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class MathGame {
private static Random random = new Random();
public int illegalArgumentCount = 0;
...
$ jad demo.MathGame main
ClassLoader:
+-sun.misc.Launcher$AppClassLoader@232204a1
+-sun.misc.Launcher$ExtClassLoader@7f31245a
Location:
/private/tmp/math-game.jar
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
while (true) {
/*16*/ game.run();
/*17*/ TimeUnit.SECONDS.sleep(1L);
}
}
--lineNumber
\u53C2\u6570\u9ED8\u8BA4\u503C\u4E3A true\uFF0C\u663E\u793A\u6307\u5B9A\u4E3A false \u5219\u4E0D\u6253\u5370\u884C\u53F7\u3002
$ jad demo.MathGame main --lineNumber false
ClassLoader:
+-sun.misc.Launcher$AppClassLoader@232204a1
+-sun.misc.Launcher$ExtClassLoader@7f31245a
Location:
/private/tmp/math-game.jar
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
while (true) {
game.run();
TimeUnit.SECONDS.sleep(1L);
}
}
\u63D0\u793A
\u5F53\u6709\u591A\u4E2A ClassLoader
\u90FD\u52A0\u8F7D\u4E86\u8FD9\u4E2A\u7C7B\u65F6\uFF0Cjad
\u547D\u4EE4\u4F1A\u8F93\u51FA\u5BF9\u5E94 ClassLoader
\u5B9E\u4F8B\u7684 hashcode
\uFF0C\u7136\u540E\u4F60\u53EA\u9700\u8981\u91CD\u65B0\u6267\u884C jad
\u547D\u4EE4\uFF0C\u5E76\u4F7F\u7528\u53C2\u6570 -c <hashcode>
\u5C31\u53EF\u4EE5\u53CD\u7F16\u8BD1\u6307\u5B9A ClassLoader \u52A0\u8F7D\u7684\u90A3\u4E2A\u7C7B\u4E86\uFF1B
$ jad org.apache.log4j.Logger
Found more than one class for: org.apache.log4j.Logger, Please use jad -c hashcode org.apache.log4j.Logger
HASHCODE CLASSLOADER
69dcaba4 +-monitor's ModuleClassLoader
6e51ad67 +-java.net.URLClassLoader@6e51ad67
+-sun.misc.Launcher$AppClassLoader@6951a712
+-sun.misc.Launcher$ExtClassLoader@6fafc4c2
2bdd9114 +-pandora-qos-service's ModuleClassLoader
4c0df5f8 +-pandora-framework's ModuleClassLoader
Affect(row-cnt:0) cost in 38 ms.
$ jad org.apache.log4j.Logger -c 69dcaba4
ClassLoader:
+-monitor's ModuleClassLoader
Location:
/Users/admin/app/log4j-1.2.14.jar
package org.apache.log4j;
import org.apache.log4j.spi.*;
public class Logger extends Category
{
private static final String FQCN;
protected Logger(String name)
{
super(name);
}
...
Affect(row-cnt:1) cost in 190 ms.
\u5BF9\u4E8E\u53EA\u6709\u552F\u4E00\u5B9E\u4F8B\u7684 ClassLoader \u8FD8\u53EF\u4EE5\u901A\u8FC7--classLoaderClass
\u6307\u5B9A class name\uFF0C\u4F7F\u7528\u8D77\u6765\u66F4\u52A0\u65B9\u4FBF\uFF1A
--classLoaderClass
\u7684\u503C\u662F ClassLoader \u7684\u7C7B\u540D\uFF0C\u53EA\u6709\u5339\u914D\u5230\u552F\u4E00\u7684 ClassLoader \u5B9E\u4F8B\u65F6\u624D\u80FD\u5DE5\u4F5C\uFF0C\u76EE\u7684\u662F\u65B9\u4FBF\u8F93\u5165\u901A\u7528\u547D\u4EE4\uFF0C\u800C-c <hashcode>
\u662F\u52A8\u6001\u53D8\u5316\u7684\u3002