mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
update doc
This commit is contained in:
@@ -20,3 +20,5 @@ mc -d /tmp/output /tmp/ClassA.java /tmp/ClassB.java
|
||||
```
|
||||
|
||||
编译生成`.class`文件之后,可以结合[redefine](redefine.md)命令实现热更新代码。
|
||||
|
||||
> 注意,mc命令有可能失败。如果编译失败可以在本地编译好`.class`文件,再上传到服务器。具体参考[redefine](redefine.md)命令说明。
|
||||
@@ -37,6 +37,26 @@ redefine /tmp/com/example/demo/arthas/user/UserController.class
|
||||
* mc命令来内存编译修改过的代码
|
||||
* 用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的限制
|
||||
|
||||
* 不允许新增加field/method
|
||||
|
||||
@@ -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.
|
||||
|
||||
> 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
|
||||
* 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
|
||||
|
||||
|
||||
@@ -210,6 +210,8 @@
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>After compiling the <tt class="docutils literal">.class</tt> file, you can use the <a class="reference internal" href="redefine.html"><span class="doc">redefine</span></a> command to re-define the loaded classes in JVM.</p>
|
||||
<blockquote>
|
||||
<div>Note that the mc command may fail. If the compilation fails, the <tt class="docutils literal">.class</tt> file can be compiled locally and uploaded to the server. Refer to the <a class="reference internal" href="redefine.html"><span class="doc">redefine</span></a> command description for details.</div></blockquote>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="#options">Options</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#use-with-the-jad-mc-command">Use with the jad/mc command</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#tips-for-uploading-class-files-to-the-server">Tips for uploading .class files to the server</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#restrictions-of-the-redefine-command">Restrictions of the redefine command</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -249,6 +250,25 @@ redefine /tmp/com/example/demo/arthas/user/UserController.class
|
||||
<li>Load new bytecode with <tt class="docutils literal">redefine</tt> command</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="tips-for-uploading-class-files-to-the-server">
|
||||
<span id="tips-for-uploading-class-files-to-the-server"></span><h2>Tips for uploading .class files to the server<a class="headerlink" href="#tips-for-uploading-class-files-to-the-server" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The <tt class="docutils literal">mc</tt> 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 <tt class="docutils literal">base64</tt> command to bypass.</p>
|
||||
<ol>
|
||||
<li><p class="first">Convert the <tt class="docutils literal">.class</tt> file to base64 first, then save it as result.txt</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">Base64 < Test.class > result.txt
|
||||
</pre></div>
|
||||
</div>
|
||||
</li>
|
||||
<li><p class="first">Login the server, create and edit <tt class="docutils literal">result.txt</tt>, copy the local content, paste and save</p>
|
||||
</li>
|
||||
<li><p class="first">Restore <tt class="docutils literal">result.txt</tt> on the server to <tt class="docutils literal">.class</tt></p>
|
||||
<div class="highlight-default notranslate"><pre class="literal-block">Base64 -d < result.txt > Test.class</pre>
|
||||
</div>
|
||||
</li>
|
||||
<li><p class="first">Use the md5 command to verify that the <tt class="docutils literal">.class</tt> files are consistent.</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="restrictions-of-the-redefine-command">
|
||||
<span id="restrictions-of-the-redefine-command"></span><h2>Restrictions of the redefine command<a class="headerlink" href="#restrictions-of-the-redefine-command" title="Permalink to this headline">¶</a></h2>
|
||||
<ul>
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -212,6 +212,8 @@
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>编译生成<tt class="docutils literal">.class</tt>文件之后,可以结合<a class="reference internal" href="redefine.html"><span class="doc">redefine</span></a>命令实现热更新代码。</p>
|
||||
<blockquote>
|
||||
<div>注意,mc命令有可能失败。如果编译失败可以在本地编译好<tt class="docutils literal">.class</tt>文件,再上传到服务器。具体参考<a class="reference internal" href="redefine.html"><span class="doc">redefine</span></a>命令说明。</div></blockquote>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="#">参数说明</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#">使用参考</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#jad-mc">结合 jad/mc 命令使用</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#class">上传 .class 文件到服务器的技巧</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#redefine">redefine的限制</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -251,6 +252,25 @@ redefine /tmp/com/example/demo/arthas/user/UserController.class
|
||||
<li>用redefine命令加载新的字节码</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="class">
|
||||
<span id="class"></span><h2>上传 .class 文件到服务器的技巧<a class="headerlink" href="#class" title="永久链接至标题">¶</a></h2>
|
||||
<p>使用<tt class="docutils literal">mc</tt>命令来编译<tt class="docutils literal">jad</tt>的反编译的代码有可能失败。可以在本地修改代码,编译好后再上传到服务器上。有的服务器不允许直接上传文件,可以使用<tt class="docutils literal">base64</tt>命令来绕过。</p>
|
||||
<ol>
|
||||
<li><p class="first">在本地先转换<tt class="docutils literal">.class</tt>文件为base64,再保存为result.txt</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">base64 < Test.class > result.txt
|
||||
</pre></div>
|
||||
</div>
|
||||
</li>
|
||||
<li><p class="first">到服务器上,新建并编辑<tt class="docutils literal">result.txt</tt>,复制本地的内容,粘贴再保存</p>
|
||||
</li>
|
||||
<li><p class="first">把服务器上的 <tt class="docutils literal">result.txt</tt>还原为<tt class="docutils literal">.class</tt></p>
|
||||
<div class="highlight-default notranslate"><pre class="literal-block">base64 -d < result.txt > Test.class</pre>
|
||||
</div>
|
||||
</li>
|
||||
<li><p class="first">用md5命令计算哈希值,校验是否一致</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="redefine">
|
||||
<span id="id3"></span><h2>redefine的限制<a class="headerlink" href="#redefine" title="永久链接至标题">¶</a></h2>
|
||||
<ul>
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user