{"id":164855,"date":"2013-01-06T13:12:02","date_gmt":"2013-01-06T09:12:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=164855"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=164855","title":{"rendered":"<span class=\"post_title\">\u0428\u0438\u0444\u0440\u0443\u044e\u0442\u0441\u044f? \u0412\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u0431\u0430\u0439\u0442\u043a\u043e\u0434 \u0438\u0437 JVM<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440. \u042f \u043f\u0438\u0448\u0443 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Java, \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c, \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 MMORPG \u0438\u0433\u0440. \u0421\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0435 \u00ab\u0441\u0431\u043e\u0440\u043a\u0438\u00bb \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0444\u0435\u0440\u0435. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043b\u0430\u0442\u043d\u043e, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0438 \u0442\u0432\u043e\u0440\u0435\u043d\u0438\u044f. \u0421 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0440, \u0441\u0442\u0430\u043b\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u043e\u043c\u0438\u043c\u043e \u0441\u0438\u0441\u0442\u0435\u043c \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442. \u0418, \u043a\u0430\u043a \u0432\u043e\u0434\u0438\u0442\u0441\u044f, \u0441 \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435 \u0438 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c, \u043c\u043d\u043e\u044e \u043e\u0432\u043b\u0430\u0434\u0435\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441 (\u0447\u0438\u0441\u0442\u043e \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439), \u043a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438.<br \/>  <a name=\"habracut\"><\/a>   <\/p>\n<h3>\u041a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442<\/h3>\n<p>  \u0414\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f\u0434\u0440\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (jar) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c RC4, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044f \u0443\u0436\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0431\u044b \u0437\u0430\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043b\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u041f\u044b\u0442\u0430\u044f\u0441\u044c \u0434\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u043b\u0438\u0431\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0434\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u043b\u0438\u0431\u043e \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/screenshot.ru\/screens\/05.01.13\/23:21:43_c19ea9ae.png\" alt=\"image\"\/><\/p>\n<p>  \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. (\u0414\u0430-\u0434\u0430, \u043a\u0440\u043e\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 *nix \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442 \u043f\u043e\u0434 win \u0438 nix, \u044d\u0442\u043e\u0433\u043e \u0445\u0432\u0430\u0442\u0430\u0435\u0442). \u0412 \u043a\u043b\u0430\u0441\u0441\u043b\u043e\u0430\u0434\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 defineClass, \u043e\u043d \u0447\u0435\u0440\u0435\u0437 JNI \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 defineClass \u0432 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435, \u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0431\u0430\u0439\u0442\u043a\u043e\u0434, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430 \u0438 \u0434\u0430\u043b\u0435\u0435 \u043e\u0442\u0434\u0430\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 JVM. \u0411\u044b\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0442\u0435\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f: \u0430\u043d\u0430\u043b\u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0435\u0435 \u0445\u0443\u043a, \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c Open-JDK \u0438 \u0442\u0430\u0449\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0435. \u042f \u043f\u043e\u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b \u0443 \u0433\u0443\u0433\u043b\u0430, \u043d\u0435\u0442 \u043b\u0438 \u0435\u0449\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0443\u0436\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u0439\u0442\u043a\u043e\u0434 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 JVM. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0435\u0441\u0442\u044c, \u0438 \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 java.lang.instrument.Instrumentation, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0430\u0442\u0442\u0430\u0447\u0435 \u0430\u0433\u0435\u043d\u0442\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 retransformClasses(Class[] classes). \u0427\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442? \u0410 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c. \u0410 \u0442\u043e\u0447\u043d\u0435\u0435 \u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 ClassFileTransformer. \u0412\u043e\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"java\">public byte[] transform(ClassLoader loader, String className, Class&lt;?&gt; classBeingRedefined, \t                        ProtectionDomain protectionDomain, \t                        byte[] classfileBuffer) throws IllegalClassFormatException<\/code><\/pre>\n<p>  \u042d\u0432\u0440\u0438\u043a\u0430! byte[] classfileBuffer \u2013 \u0442\u043e, \u0447\u0442\u043e \u0442\u0430\u043c \u043d\u0443\u0436\u043d\u043e! \u042d\u0442\u043e \u0443\u0436\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u0439\u0442\u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e. (\u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0438\u0436\u0435).<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e Instrumentation \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0430\u0442\u0442\u0430\u0447\u0430 \u0430\u0433\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"java\">public static void agentmain(String agentArgs, Instrumentation inst) {     \tinst.addTransformer(new ClassFileTransformerImpl(), true);  \tinst.retransformClasses(inst.getAllLoadedClasses()); \/\/ \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0435\u043c\u0443 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0443 \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 }<\/code><\/pre>\n<p>  \u0420\u044b\u0447\u0430\u0433\u0438 \u0432\u043e\u0437\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u044b \u043d\u0430\u0448\u043b\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443. \u0411\u0443\u0434\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u0430 \u0432 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c pid \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0430\u0442\u0442\u0430\u0447\u0435\u0440\u0430, \u043d\u043e \u043c\u044b \u0436\u0435 \u0445\u043e\u0442\u0438\u043c \u043a\u0440\u0430\u0441\u043e\u0442\u044b \u0438 \u0438\u0437\u044b\u0441\u043a\u0430! \u041d\u0443 \u0447\u0442\u043e \u0436\u0435, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 GUI, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0441\u0430\u043c\u0430. <\/p>\n<h3>\u041a \u0434\u0435\u043b\u0443!<\/h3>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u0432\u044b\u044f\u0441\u043d\u044f\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c pid \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f jdk.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 pid \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 jvm \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043c\u0435\u0442\u043e\u0434 com.sun.tools.attach.VirtualMachine.list(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 jvm. \u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0438\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b \u043d\u0430\u0448 GUI, \u0432\u044b\u0432\u043e\u0434\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 JVM \u0438 id \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041d\u043e \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0436\u0443\u0442\u043a\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0437\u0431\u043e\u0436\u043d\u043e \u043e\u0442\u044a\u0435\u0434\u0430\u043b \u043f\u0430\u043c\u044f\u0442\u044c. \u0414\u0430 \u0438 \u043d\u0435\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u0434\u043e\u043b\u0436\u0435\u043d \u0436\u0435 \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u043c\u0435\u0442\u043e\u0434, \u043a\u0430\u043a \u0443, \u0441\u043a\u0430\u0436\u0435\u043c, \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u043e\u0432. \u0418 \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u044f \u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442 jdk, \u043f\u043e\u0438\u0437\u0443\u0447\u0430\u043b, \u0438 \u043d\u0430\u0448\u0435\u043b \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043b\u0438\u0441\u0435\u043d\u0435\u0440. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u0435\u0435, \u0438 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<pre><code class=\"java\">import sun.jvmstat.monitor.MonitoredHost; import sun.jvmstat.monitor.event.HostEvent; import sun.jvmstat.monitor.event.HostListener; import sun.jvmstat.monitor.event.VmStatusChangeEvent;  public class VMUpdater {  \tpublic static MonitoredHost MH;  \tpublic VMUpdater() { \t\ttry { \t\t\tMH = MonitoredHost.getMonitoredHost(&quot;localhost&quot;); \t\t\tMH.addHostListener(new HostListenerAction()); \t\t} catch (Exception e) {} \t}  \tprivate class HostListenerAction implements HostListener {  \t\t@Override \t\tpublic void vmStatusChanged(VmStatusChangeEvent vmStatusChangeEvent) {}  \t\t@Override \t\tpublic void disconnected(HostEvent hostEvent) {} \t}  } <\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 vmStatusChanged \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 GUI.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0446\u0435\u043b\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u0430, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0430\u0433\u0435\u043d\u0442.<\/p>\n<pre><code class=\"java\"> \tprivate static final String PATH = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); \t \tprivate static VirtualMachine vm;  \/\/\u0421\u044e\u0434\u0430 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c pid \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c \u0438\u0437 GUI \tpublic static void attach(int pid) throws Exception { \t\tvm = VirtualMachine.attach(String.valueOf(pid)); \t\tvm.loadAgent(PATH); \/\/\u043f\u0443\u0442\u044c \u0434\u043e jar c \u0430\u0442\u0442\u0430\u0447\u0435\u043c (\u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435) \t\tAttachedGUI.getInstance().draw(); \/\/\u0420\u0438\u0441\u0443\u0435\u043c GUI \t} <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e? \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u2013 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e jar. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c. \u0412 GUI \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c jar, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0430\u0433\u0435\u043d\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a \u0442\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043d\u0430\u043c \u0441\u0432\u043e\u0439 \u043a\u0430\u043d\u0430\u043b \u0441\u0432\u044f\u0437\u0438 \u2013 RMI.<br \/>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043f\u0443\u0442\u044c jar, \u0438\u0449\u0435\u043c \u0435\u0435, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0435 \u043a\u043b\u0430\u0441\u0441\u044b. \u041d\u043e \u0432\u0435\u0434\u044c \u043d\u0435 \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0441\u043a\u0430\u0436\u0435\u0442\u0435 \u0432\u044b! \u0418 \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043f\u0440\u0430\u0432\u044b. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u043b\u043e\u0430\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442 \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u0437 jar \u0438 \u043e\u0442\u0434\u0430\u0435\u043c \u0438\u0445 \u043d\u0430\u0448\u0435\u043c\u0443 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u043b\u0430\u0433\u043e\u043f\u043e\u043b\u0443\u0447\u043d\u043e \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u0438\u0442 \u0432 \u043a\u0443\u0447\u043a\u0443. <\/p>\n<pre><code class=\"java\"> import java.io.BufferedInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import java.util.jar.JarEntry; import java.util.jar.JarFile;  public class JarClassLoader extends ClassLoader { \t \tprivate Hashtable&lt;String, Class&lt;?&gt;&gt; classes = new Hashtable&lt;String, Class&lt;?&gt;&gt;(); \t \tpublic JarClassLoader(ClassLoader parent) { \t\tsuper(parent); \t}  \t@Override \tpublic synchronized Class&lt;?&gt; loadClass(String className, boolean resolve) \t\t\tthrows ClassNotFoundException { \t\tClass&lt;?&gt; result = null; \t\tresult = classes.get(className); \t\t \t\tif(result == null) \t\t\tresult = super.findSystemClass(className); \t\tif(result == null) \t\t\tresult = super.loadClass(className); \t\t \t\tclasses.put(className, result); \t\treturn result; \t} \t \tpublic Hashtable&lt;String, Class&lt;?&gt;&gt; loadJar(String jarPath, String dumpPath) throws IOException, ClassNotFoundException { \t\tclasses.clear(); \t\tJarFile jar = new JarFile(jarPath); \t\tEnumeration&lt;JarEntry&gt; entries = jar.entries(); \t\twhile (entries.hasMoreElements()) { \t\t\tString name = entries.nextElement().getName(); \t\t\tif(name.endsWith(&quot;.class&quot;)) { \t\t\t\tString className = name; \t\t\t\tif(name.contains(&quot;.&quot;)) \t\t\t\t\tclassName = name.substring(0, name.lastIndexOf(&quot;.&quot;)).replace(&quot;\/&quot;, &quot;.&quot;); \t\t\t\tClass&lt;?&gt; c = loadClass(className); \t\t\t\tif(c != null) \t\t\t\t\tclasses.put(className, c); \t\t\t} else if(jar.getEntry(name).isDirectory()) { \t\t\t\tname = slash2sep(name); \t\t\t\tnew File(dumpPath + File.separator + name).mkdirs(); \t\t\t} else { \t\t\t\tFileOutputStream fos = new FileOutputStream(dumpPath + File.separator + name); \t\t\t\tBufferedInputStream bis = new BufferedInputStream(jar.getInputStream(jar.getEntry(name))); \t\t\t\tbyte[] data = new byte[(int) jar.getEntry(name).getSize()]; \t\t\t\tbis.read(data); \t\t\t\tfos.write(data); \t\t\t\tbis.close(); \t\t\t\tfos.close(); \t\t\t} \t\t} \t\tjar.close(); \t\treturn classes; \t}  \tprivate static String slash2sep(String src) { \t\tint i; \t\tchar[] chDst = new char[src.length()]; \t\tString dst;  \t\tfor(i = 0; i &lt; src.length(); i++) { \t\t\tif(src.charAt(i) == '\/') \t\t\t\tchDst[i] = File.separatorChar; \t\t\telse \t\t\t\tchDst[i] = src.charAt(i); \t\t} \t\tdst = new String(chDst); \t\treturn dst; \t} \t } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c \u2013 \u0437\u0430\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u0442 (\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0441\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 gui, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 rmi).<\/p>\n<p>  \u0418 \u0434\u0430, \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0435\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442 (\u043f\u0443\u0441\u0442\u044c, \u043c\u0435\u0439\u043d-\u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f ClassDumperAgent):<\/p>\n<pre><code class=\"java\">Premain-Class: ClassDumperAgent Agent-Class: ClassDumperAgent Can-Redefine-Classes: true Can-Retransform-Classes: true<\/code><\/pre>\n<p>  \u041d\u0443, \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043f\u0430\u0440\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432. \u0411\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0432\u0441\u0435\u0439 jar, \u0430 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 \u0438 \u0435\u0449\u0435 \u043f\u0430\u0440\u0430 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0444\u0438\u0448\u0435\u043a, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/screenshot.ru\/screens\/06.01.13\/02:05:05_aab91b69.png\" alt=\"image\"\/><br \/>  <img decoding=\"async\" src=\"http:\/\/screenshot.ru\/screens\/06.01.13\/02:04:19_40bc35dc.png\" alt=\"image\"\/><\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 <a href=\"https:\/\/bitbucket.org\/ioexception\/class-dumper\/src\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/a>. \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/164855\/\"> http:\/\/habrahabr.ru\/post\/164855\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440. \u042f \u043f\u0438\u0448\u0443 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Java, \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c, \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 MMORPG \u0438\u0433\u0440. \u0421\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0435 \u00ab\u0441\u0431\u043e\u0440\u043a\u0438\u00bb \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0444\u0435\u0440\u0435. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043b\u0430\u0442\u043d\u043e, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0438 \u0442\u0432\u043e\u0440\u0435\u043d\u0438\u044f. \u0421 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0440, \u0441\u0442\u0430\u043b\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u043e\u043c\u0438\u043c\u043e \u0441\u0438\u0441\u0442\u0435\u043c \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442. \u0418, \u043a\u0430\u043a \u0432\u043e\u0434\u0438\u0442\u0441\u044f, \u0441 \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435 \u0438 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c, \u043c\u043d\u043e\u044e \u043e\u0432\u043b\u0430\u0434\u0435\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441 (\u0447\u0438\u0441\u0442\u043e \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439), \u043a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-164855","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/164855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=164855"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/164855\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=164855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=164855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=164855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}