mirror of https://github.com/alibaba/arthas.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
Markdown
39 lines
1.1 KiB
Markdown
3 years ago
|
# mc
|
||
6 years ago
|
|
||
4 years ago
|
[`mc-retransform` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-mc-retransform)
|
||
5 years ago
|
|
||
3 years ago
|
::: tip
|
||
|
Memory compiler, compiles `.java` files into `.class` files in memory.
|
||
|
:::
|
||
6 years ago
|
|
||
|
```bash
|
||
|
mc /tmp/Test.java
|
||
|
```
|
||
|
|
||
|
The classloader can be specified with the `-c` option:
|
||
|
|
||
|
```bash
|
||
|
mc -c 327a647b /tmp/Test.java
|
||
|
```
|
||
|
|
||
5 years ago
|
You can also specify the ClassLoader with the `--classLoaderClass` option:
|
||
|
|
||
|
```bash
|
||
|
$ mc --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader /tmp/UserController.java -d /tmp
|
||
|
Memory compiler output:
|
||
|
/tmp/com/example/demo/arthas/user/UserController.class
|
||
|
Affect(row-cnt:1) cost in 346 ms
|
||
|
```
|
||
|
|
||
6 years ago
|
The output directory can be specified with the `-d` option:
|
||
|
|
||
|
```bash
|
||
|
mc -d /tmp/output /tmp/ClassA.java /tmp/ClassB.java
|
||
|
```
|
||
|
|
||
4 years ago
|
After compiling the `.class` file, you can use the [retransform](retransform.md) command to re-define the loaded classes in JVM.
|
||
6 years ago
|
|
||
3 years ago
|
::: warning
|
||
|
Note that the mc command may fail. If the compilation fails, the `.class` file can be compiled locally and uploaded to the server. Refer to the [retransform](retransform.md) command description for details.
|
||
|
:::
|