<div class="__aliyun_email_body_block"><div  style="line-height:1.7;font-family:tahoma;font-size:14.0px;color:#000000;"><div  style="clear:both;"><span  style="color:#171a1d;font-family:Helvetica,Tahoma,Arial;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">> </span><span  style="color:#171a1d;font-family:Helvetica,Tahoma,Arial;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">how would you safeguard such a facility?<br ><br >It connects target VM via unix domain socket, they are all in local machine, no safeguard is needed because we even have "kill -9 <pid>" or "gcore -o x <pid>"<br ><br ><br ></span></div><div  id="haloword-title" style="position:relative;"><span ></span><audio  id="haloword-audio"></audio><div  id="haloword-control-container"><span ></span><span ></span><a  class="haloword-button" href="#" id="haloword-open" target="_blank" title="查看单词详细释义"></a><span ></span></div><br  style="clear:both;"></div><div  style="clear:both;"><br /></div><blockquote  style="margin-right:0;margin-top:0;margin-bottom:0;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><div  style="clear:both;">------------------------------------------------------------------</div><div  style="clear:both;">From:David Holmes <david.holmes@oracle.com></div><div  style="clear:both;">Send Time:2023 Jul. 13 (Thu.) 20:34</div><div  style="clear:both;">To:"YANG, Yi" <qingfeng.yy@alibaba-inc.com>; jdk-dev <jdk-dev@openjdk.org></div><div  style="clear:both;">Subject:Re: Proposal: Post debug Java code to target JVM and exec it</div><div  style="clear:both;"><br /></div>On 13/07/2023 8:57 pm, Yi Yang wrote:<br >> Proposal: Post debug Java code to target JVM and exec it<br >> <br >> Hello, I have an early idea to post a piece of Java code to a local JVM <br >> process via jcmd or jexec, like this:<br >> <br >> jcmd VM.exec Debug.java<br >> jexec Debug.java<br >> <br >> class Debug {<br >> public static void main(){<br >> ApplicationProperties c = loadClass("ApplicationProperties");<br >> // print static field of running Java program<br >> System.out.println(ApplicationProperties.field1);<br >> // call static method of running Java program<br >> ApplicationProperties.printAll();<br >> // ....<br >> }<br >> }<br >> <br >> With this approach, we can do some useful things, such as:<br >> - Get some runtime data of the program<br >> - Troubleshoot Java problems<br >> - In rare cases, it can also assist in JVM problem diagnosis<br >> <br >> To protect the attach listener, we may need to create a new ExecThread <br >> at JVM startup and execute Debug::main in this thread. Do you have any <br >> comments on this idea?<br ><br >So basically you want the ability to ask a running JVM to execute an <br >arbitrary piece of java code. That may have some uses but in general <br >seems incredibly dangerous - how would you safeguard such a facility?<br ><br >Cheers,<br >David<br ><br >> Thank you.</blockquote></div></div>