{"action":"created","issue":{"url":"https://api.github.com/repos/alibaba/arthas/issues/403","repository_url":"https://api.github.com/repos/alibaba/arthas","labels_url":"https://api.github.com/repos/alibaba/arthas/issues/403/labels{/name}","comments_url":"https://api.github.com/repos/alibaba/arthas/issues/403/comments","events_url":"https://api.github.com/repos/alibaba/arthas/issues/403/events","html_url":"https://github.com/alibaba/arthas/issues/403","id":393863777,"node_id":"MDU6SXNzdWUzOTM4NjM3Nzc=","number":403,"title":"请教Enhancer.spy方法中，为何又要init一次Spy？","user":{"login":"houseyoung","id":7338409,"node_id":"MDQ6VXNlcjczMzg0MDk=","avatar_url":"https://avatars1.githubusercontent.com/u/7338409?v=4","gravatar_id":"","url":"https://api.github.com/users/houseyoung","html_url":"https://github.com/houseyoung","followers_url":"https://api.github.com/users/houseyoung/followers","following_url":"https://api.github.com/users/houseyoung/following{/other_user}","gists_url":"https://api.github.com/users/houseyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/houseyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houseyoung/subscriptions","organizations_url":"https://api.github.com/users/houseyoung/orgs","repos_url":"https://api.github.com/users/houseyoung/repos","events_url":"https://api.github.com/users/houseyoung/events{/privacy}","received_events_url":"https://api.github.com/users/houseyoung/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-24T11:26:36Z","updated_at":"2018-12-25T02:00:22Z","closed_at":null,"author_association":"NONE","body":"在启动的时候AgentBootstrap中已经调用了Spy.initForAgentLauncher来初始化Spy，为何要在Enhancer.spy方法再次调用Spy.init来再次初始化一次？初始化的时候，代码如下：\r\n\r\n>\r\n        Method initMethod = spyClass.getMethod(\"init\", ClassLoader.class, Method.class,\r\n                Method.class, Method.class, Method.class, Method.class, Method.class);\r\n        initMethod.invoke(null, arthasClassLoader,\r\n                FieldUtils.getField(spyClass, \"ON_BEFORE_METHOD\").get(null),\r\n                FieldUtils.getField(spyClass, \"ON_RETURN_METHOD\").get(null),\r\n                FieldUtils.getField(spyClass, \"ON_THROWS_METHOD\").get(null),\r\n                FieldUtils.getField(spyClass, \"BEFORE_INVOKING_METHOD\").get(null),\r\n                FieldUtils.getField(spyClass, \"AFTER_INVOKING_METHOD\").get(null),\r\n                FieldUtils.getField(spyClass, \"THROW_INVOKING_METHOD\").get(null));\r\n\r\n这段代码我理解是把Spy中Field的值（即AdviceWeaver中对应的Method），再次init回Spy中的对应Field，请问这样做的目的何在？\r\n\r\nGreys这段代码的注释是：\r\n        // 无论从哪里取到spyClass，都需要重新初始化一次\r\n        // 用以兼容重新加载的场景\r\n        // 当然，这样做会给渲染的过程带来一定的性能开销，不过能简化编码复杂度\r\nArthas这段代码的注释是：\r\n        // 初始化间谍, AgentLauncher会把各种hook设置到ArthasClassLoader当中\r\n        // 这里我们需要把这些hook取出来设置到目标classloader当中\r\n我都没有看明白具体是什么意思…请赐教！"},"comment":{"url":"https://api.github.com/repos/alibaba/arthas/issues/comments/449786881","html_url":"https://github.com/alibaba/arthas/issues/403#issuecomment-449786881","issue_url":"https://api.github.com/repos/alibaba/arthas/issues/403","id":449786881,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTc4Njg4MQ==","user":{"login":"houseyoung","id":7338409,"node_id":"MDQ6VXNlcjczMzg0MDk=","avatar_url":"https://avatars1.githubusercontent.com/u/7338409?v=4","gravatar_id":"","url":"https://api.github.com/users/houseyoung","html_url":"https://github.com/houseyoung","followers_url":"https://api.github.com/users/houseyoung/followers","following_url":"https://api.github.com/users/houseyoung/following{/other_user}","gists_url":"https://api.github.com/users/houseyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/houseyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houseyoung/subscriptions","organizations_url":"https://api.github.com/users/houseyoung/orgs","repos_url":"https://api.github.com/users/houseyoung/repos","events_url":"https://api.github.com/users/houseyoung/events{/privacy}","received_events_url":"https://api.github.com/users/houseyoung/received_events","type":"User","site_admin":false},"created_at":"2018-12-25T02:00:22Z","updated_at":"2018-12-25T02:00:22Z","author_association":"NONE","body":"@hengyunabc 我理解这种情况应该很罕见吧……绝大多数应用都不会扫到Spy然后加载进去吧？"}}
{"actor":{"display_login":"houseyoung"}}