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>`.
```bash
$ 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.
* PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it's jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.
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.
Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader using `sc -d <ClassName>`.
if you use`-c`, you have to manually type hashcode by `-c <hashcode>`.
```bash
$ getstatic -c 3d4eac69 demo.MathGame random
```
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
* PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it's jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.
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.
Tip: if the static field is a complex class, you can even use [`OGNL`](https://commons.apache.org/proper/commons-ognl/language-guide.html) to traverse, filter and access the inner properties of this class.
Tip: if the static field is a complex class, you can even use [`OGNL`](https://commons.apache.org/proper/commons-ognl/language-guide.html) to traverse, filter and access the inner properties of this class.
|`[c:]`|hashcode of the class loader that loads the class|
|`[c:]`|hashcode of the class loader that loads the class|
|`[classLoaderClass:]`| The class name of the ClassLoader that executes the expression. |
|`[E]`|turn on regex match while the default is wildcard match|
|`[E]`|turn on regex match while the default is wildcard match|
### Usage
### Usage
@ -143,3 +144,7 @@ public class Logger extends Category
Affect(row-cnt:1) cost in 190 ms.
Affect(row-cnt:1) cost in 190 ms.
```
```
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
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.
By default,logger command will be executed under SystemClassloader, if the application is a traditional `war`, or using spring boot fat jar, then it needs to specify classloader。
@ -48,21 +48,25 @@ It can be found that it is loaded by spring boot `LaunchedURLClassLoader@1be6f5c
Please write down your classLoaderHash here, in the case here, it's `1be6f5c3`. It will be used in the future steps.
Please write down your classLoaderHash here, in the case here, it's `1be6f5c3`. It will be used in the future steps.
Note: Please replace `<classLoaderHash>` with your classLoaderHash above, then execute the related commands manually in the following steps:
### mc
### mc
After saving `/tmp/UserController.java`, compile with the `mc` (Memory Compiler) command and specify the ClassLoader with the `-c` option:
After saving `/tmp/UserController.java`, compile with the `mc` (Memory Compiler) command and specify the ClassLoader with the `-c` or `--classLoaderClass` option:
It can be found that it is loaded by spring boot `LaunchedURLClassLoader@1be6f5c3`.
It can be found that it is loaded by spring boot `LaunchedURLClassLoader@1be6f5c3`.
Please write down your classLoaderHash here, in the case here, it's `1be6f5c3`. It will be used in the future steps.
Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader.
Note: Please replace `<classLoaderHash>` with your classLoaderHash above, then execute the commands manually in the following steps:
if you use`-c`, you have to manually type hashcode by `-c <hashcode>`.
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
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.
### mc
### mc
After saving `/tmp/UserController.java`, compile with the `mc` (Memory Compiler) command and specify the ClassLoader with the `-c` option:
After saving `/tmp/UserController.java`, compile with the `mc` (Memory Compiler) command and specify the ClassLoader with the `--classLoaderClass` option:
|`[c:]`|hashcode of the [class loader](classloader.md) that loaded the target class|
|`[c:]`|hashcode of the [class loader](classloader.md) that loaded the target class|
|`[classLoaderClass:]`| The class name of the ClassLoader that executes the expression. |
|`[d:]`|set the destination directory for class files|
|`[d:]`|set the destination directory for class files|
|`[E]`|turn on regex match, the default behavior is wild card match|
|`[E]`|turn on regex match, the default behavior is wild card match|
@ -39,3 +40,29 @@ $ dump
null /tmp/output/java/lang/String.class
null /tmp/output/java/lang/String.class
Affect(row-cnt:1) cost in 138 ms.
Affect(row-cnt:1) cost in 138 ms.
```
```
* Specify classLoader
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>`.
```bash
$ 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.
* PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it's jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.
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.
Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader using `sc -d <ClassName>`.
if you use`-c`, you have to manually type hashcode by `-c <hashcode>`.
```bash
$ getstatic -c 3d4eac69 demo.MathGame random
```
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
* PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it's jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.
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.
Tip: if the static field is a complex class, you can even use [`OGNL`](https://commons.apache.org/proper/commons-ognl/language-guide.html) to traverse, filter and access the inner properties of this class.
Tip: if the static field is a complex class, you can even use [`OGNL`](https://commons.apache.org/proper/commons-ognl/language-guide.html) to traverse, filter and access the inner properties of this class.
|`[c:]`|hashcode of the class loader that loads the class|
|`[c:]`|hashcode of the class loader that loads the class|
|`[classLoaderClass:]`| The class name of the ClassLoader that executes the expression. |
|`[E]`|turn on regex match while the default is wildcard match|
|`[E]`|turn on regex match while the default is wildcard match|
### Usage
### Usage
@ -149,3 +150,7 @@ public class Logger extends Category
Affect(row-cnt:1) cost in 190 ms.
Affect(row-cnt:1) cost in 190 ms.
```
```
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
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.
By default,logger command will be executed under SystemClassloader, if the application is a traditional `war`, or using spring boot fat jar, then it needs to specify classloader。
It can be found that it is loaded by spring boot `LaunchedURLClassLoader@1be6f5c3`.
It can be found that it is loaded by spring boot `LaunchedURLClassLoader@1be6f5c3`.
Please write down your classLoaderHash here, in the case here, it's `1be6f5c3`. It will be used in the future steps.
Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader.
Note: Please replace `<classLoaderHash>` with your classLoaderHash above, then execute the commands manually in the following steps:
if you use`-c`, you have to manually type hashcode by `-c <hashcode>`.
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
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.
### mc
### mc
After saving `/tmp/UserController.java`, compile with the `mc` (Memory Compiler) command and specify the ClassLoader with the `-c` option:
After saving `/tmp/UserController.java`, compile with the `mc` (Memory Compiler) command and specify the ClassLoader with the `--classLoaderClass` option: