mirror of
https://github.com/alibaba/arthas.git
synced 2026-11-30 15:33:59 +00:00
update doc
This commit is contained in:
1 parent
5e146c1bb7
commit
88ed7897bd
4 files changed
+44
No files matched your search
@@ -20,3 +20,5 @@ mc -d /tmp/output /tmp/ClassA.java /tmp/ClassB.java
|
|||||||
```
|
```
|
||||||
|
|
||||||
After compiling the `.class` file, you can use the [redefine](redefine.md) command to re-define the loaded classes in JVM.
|
After compiling the `.class` file, you can use the [redefine](redefine.md) command to re-define the loaded classes in JVM.
|
||||||
|
|
||||||
|
> 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 [redefine](redefine.md) command description for details.
|
||||||
@@ -36,6 +36,26 @@ redefine /tmp/com/example/demo/arthas/user/UserController.class
|
|||||||
* `mc` command to compile the modified code
|
* `mc` command to compile the modified code
|
||||||
* Load new bytecode with `redefine` command
|
* Load new bytecode with `redefine` command
|
||||||
|
|
||||||
|
### Tips for uploading .class files to the server
|
||||||
|
|
||||||
|
The `mc` command may fail. You can modify the code locally, compile it, and upload it to the server. Some servers do not allow direct uploading files, you can use the `base64` command to bypass.
|
||||||
|
|
||||||
|
1. Convert the `.class` file to base64 first, then save it as result.txt
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Base64 < Test.class > result.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Login the server, create and edit `result.txt`, copy the local content, paste and save
|
||||||
|
|
||||||
|
3. Restore `result.txt` on the server to `.class`
|
||||||
|
|
||||||
|
```
|
||||||
|
Base64 -d < result.txt > Test.class
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Use the md5 command to verify that the `.class` files are consistent.
|
||||||
|
|
||||||
|
|
||||||
### Restrictions of the redefine command
|
### Restrictions of the redefine command
|
||||||
|
|
||||||
|
|||||||
@@ -20,3 +20,5 @@ mc -d /tmp/output /tmp/ClassA.java /tmp/ClassB.java
|
|||||||
```
|
```
|
||||||
|
|
||||||
编译生成`.class`文件之后,可以结合[redefine](redefine.md)命令实现热更新代码。
|
编译生成`.class`文件之后,可以结合[redefine](redefine.md)命令实现热更新代码。
|
||||||
|
|
||||||
|
> 注意,mc命令有可能失败。如果编译失败可以在本地编译好`.class`文件,再上传到服务器。具体参考[redefine](redefine.md)命令说明。
|
||||||
@@ -37,6 +37,26 @@ redefine /tmp/com/example/demo/arthas/user/UserController.class
|
|||||||
* mc命令来内存编译修改过的代码
|
* mc命令来内存编译修改过的代码
|
||||||
* 用redefine命令加载新的字节码
|
* 用redefine命令加载新的字节码
|
||||||
|
|
||||||
|
### 上传 .class 文件到服务器的技巧
|
||||||
|
|
||||||
|
使用`mc`命令来编译`jad`的反编译的代码有可能失败。可以在本地修改代码,编译好后再上传到服务器上。有的服务器不允许直接上传文件,可以使用`base64`命令来绕过。
|
||||||
|
|
||||||
|
1. 在本地先转换`.class`文件为base64,再保存为result.txt
|
||||||
|
|
||||||
|
```bash
|
||||||
|
base64 < Test.class > result.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 到服务器上,新建并编辑`result.txt`,复制本地的内容,粘贴再保存
|
||||||
|
|
||||||
|
3. 把服务器上的 `result.txt`还原为`.class`
|
||||||
|
|
||||||
|
```
|
||||||
|
base64 -d < result.txt > Test.class
|
||||||
|
```
|
||||||
|
|
||||||
|
4. 用md5命令计算哈希值,校验是否一致
|
||||||
|
|
||||||
### redefine的限制
|
### redefine的限制
|
||||||
|
|
||||||
* 不允许新增加field/method
|
* 不允许新增加field/method
|
||||||
|
|||||||
Reference in new issue
Block a user