<liclass="toctree-l3"><aclass="reference internal"href="#eliminate-the-influence-of-retransform">Eliminate the influence of retransform</a></li>
<liclass="toctree-l3"><aclass="reference internal"href="#use-with-the-jad-mc-command">Use with the jad/mc command</a></li>
<liclass="toctree-l3"><aclass="reference internal"href="#tips-for-uploading-class-files-to-the-server">Tips for uploading .class files to the server</a></li>
<liclass="toctree-l3"><aclass="reference internal"href="#restrictions-of-the-retransform-command">Restrictions of the retransform command</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas">Star me at GitHub</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas/blob/master/CONTRIBUTING.md#">Compile and debug/CONTRIBUTING</a></li>
<div><p>Load the external <codeclass="docutils literal notranslate"><spanclass="pre">*.class</span></code> files to retransform the loaded classes in JVM.</p>
<p>Load the specified .class file, then parse out the class name, and then retransform the corresponding class loaded in the jvm. Every time a <codeclass="docutils literal notranslate"><spanclass="pre">.class</span></code> file is loaded, a retransform entry is recorded.</p>
<blockquote>
<div><p>If retransform is executed multiple times to load the same class file, there will be multiple retransform entries.</p>
</div></blockquote>
</div>
<divclass="section"id="view-retransform-entry">
<h2>View retransform entry<aclass="headerlink"href="#view-retransform-entry"title="Permalink to this headline">¶</a></h2>
Id ClassName TransformCount LoaderHash LoaderClassName
1 demo.MathGame 1 null null</pre></div>
</div>
<ulclass="simple">
<li><p>TransformCount counts the times of attempts to return the .class file corresponding to the entry in the ClassFileTransformer#transform method, but it does not mean that the transform must be successful.</p></li>
<h2>Delete the specified retransform entry<aclass="headerlink"href="#delete-the-specified-retransform-entry"title="Permalink to this headline">¶</a></h2>
<div><p>Note: For the same class, when there are multiple retransform entries, if retransform is explicitly triggered, the entry added last will take effect (the one with the largest id).</p>
<h2>Eliminate the influence of retransform<aclass="headerlink"href="#eliminate-the-influence-of-retransform"title="Permalink to this headline">¶</a></h2>
<p>If you want to eliminate the impact after performing retransform on a class, you need to:</p>
<ulclass="simple">
<li><p>Delete the retransform entry corresponding to this class</p></li>
<li><p>Re-trigger retransform</p></li>
</ul>
<blockquote>
<div><p>If you do not clear all retransform entries and trigger retransform again, the retransformed classes will still take effect when arthas stop.</p>
<li><p>Use <codeclass="docutils literal notranslate"><spanclass="pre">jad</span></code> command to decompile bytecode, and then you can use other editors, such as vim to modify the source code.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">mc</span></code> command to compile the modified code</p></li>
<li><p>Load new bytecode with <codeclass="docutils literal notranslate"><spanclass="pre">retransform</span></code> command</p></li>
<h2>Tips for uploading .class files to the server<aclass="headerlink"href="#tips-for-uploading-class-files-to-the-server"title="Permalink to this headline">¶</a></h2>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">mc</span></code> 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 <codeclass="docutils literal notranslate"><spanclass="pre">base64</span></code> command to bypass.</p>
<ol>
<li><p>Convert the <codeclass="docutils literal notranslate"><spanclass="pre">.class</span></code> file to base64 first, then save it as result.txt</p>
<li><p>Login the server, create and edit <codeclass="docutils literal notranslate"><spanclass="pre">result.txt</span></code>, copy the local content, paste and save</p></li>
<li><p>Restore <codeclass="docutils literal notranslate"><spanclass="pre">result.txt</span></code> on the server to <codeclass="docutils literal notranslate"><spanclass="pre">.class</span></code></p>
<li><p>Use the md5 command to verify that the <codeclass="docutils literal notranslate"><spanclass="pre">.class</span></code> files are consistent.</p></li>
<h2>Restrictions of the retransform command<aclass="headerlink"href="#restrictions-of-the-retransform-command"title="Permalink to this headline">¶</a></h2>
<ul>
<li><p>New field/method is not allowed</p></li>
<li><p>The function that is running, no exit can not take effect, such as the new <codeclass="docutils literal notranslate"><spanclass="pre">System.out.println</span></code> added below, only the <codeclass="docutils literal notranslate"><spanclass="pre">run()</span></code> function will take effect.</p>
<divclass="highlight-java notranslate"><divclass="highlight hljs"><preclass="java">public class MathGame {
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
while (true) {
game.run();
TimeUnit.SECONDS.sleep(1);
// This doesn't work because the code keeps running in while
System.out.println("in loop");
}
}
public void run() throws InterruptedException {
// This works because the run() function ends completely every time
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<scripttype="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
<divclass="github-fork-ribbon-wrapper right">
<divclass="github-fork-ribbon">
<ahref="https://github.com/alibaba/arthas"target="_blank">Fork me at GitHub</a>