* [sm](sm.md) - check methods info for the loaded classes
* [dump](dump.md) - dump the loaded classes in byte code to the specified location
* [redefine](redefine.md) - load external `*.class` files and re-define it into JVM
* [jad](jad.md) - de-compile the specified loaded classes
* [jad](jad.md) - decompile the specified loaded classes
* [classloader](classloader.md) - check the inheritance structure, urls, class loading info for the specified class; using classloader to get the url of the resource e.g. `java/lang/String.class`
`jad` helps to de-compile the byte code running in JVM to the source code to assist you to understand the logic behind better.
`jad` helps to decompile the byte code running in JVM to the source code to assist you to understand the logic behind better.
* The de-compiled code is syntax highlighted for better readability in Arthas console.
* It is possible that there's grammar error in the de-compiled code, but it should not affect your interpretation.
* The decompiled code is syntax highlighted for better readability in Arthas console.
* It is possible that there's grammar error in the decompiled code, but it should not affect your interpretation.
### Options
@ -18,19 +18,78 @@ jad
### Usage
> If the target class is loaded by multiple classloaders, `jad` outputs the `hashcode` of the corresponding classloaders, then you can re-run `jad` and specify `-c <hashcode>` to de-compile the target class from the specified classloader.
#### Decompile `java.lang.String`
```java
$ jad java.lang.String
ClassLoader:
Location:
/*
* Decompiled with CFR 0_132.
*/
package java.lang;
import java.io.ObjectStreamField;
...
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[] arrby, int n, int n2) {
String.checkBounds(arrby, n, n2);
this.value = StringCoding.decode(arrby, n, n2);
}
...
```
#### Decompile the specified method
```java
$ jad demo.MathGame main
ClassLoader:
+-sun.misc.Launcher$AppClassLoader@3d4eac69
+-sun.misc.Launcher$ExtClassLoader@66350f69
Location:
/private/tmp/arthas-demo.jar
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
do {
game.run();
TimeUnit.SECONDS.sleep(1L);
} while (true);
}
Affect(row-cnt:1) cost in 228 ms.
```
#### Decompile with specified classLoader
> If the target class is loaded by multiple classloaders, `jad` outputs the `hashcode` of the corresponding classloaders, then you can re-run `jad` and specify `-c <hashcode>` to decompile the target class from the specified classloader.
```java
$ jad org.apache.log4j.Logger
Found more than one class for: org.apache.log4j.Logger, Please use jad -c hashcode org.apache.log4j.Logger