
访问本地启动的一个服务,结果如下,下面通过热更新,在启动成功
汉字后面增加Arthas
相关文字:

进入到相应的java进程,这里进入选择3

1. 使用jad命令来反编译目标代码
jad --source-only com.upupor.app.controller.IndexController > /tmp/IndexController.java
2. 重新打开一个窗口,编辑目标代码 vim /tmp/IndexController.java
package com.upupor.app.controller;
import com.upupor.framework.CcConstant;
import com.upupor.framework.CcResponse;
import com.upupor.framework.utils.SpringContextUtils;
import com.upupor.service.BannerService;
import io.swagger.annotations.Api;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class IndexController {
@GetMapping(value={"/"})
public CcResponse index() {
String version = SpringContextUtils.getProperty("application.version");
CcResponse ccResponse = new CcResponse();
ccResponse.setData(version);
// 修改的地方!!在 启动成功 后面添加 Arthas
ccResponse.setMessage("upupor启动成功Arthas");
return ccResponse;
}
}
3.根据IndexController
找出ClassLoader

可以获得classLoader 是 764c12b6
4.使用mc,在内存中编绎代码
使用mc(Memory Compiler)命令来编译,并且通过-c
参数指定ClassLoader
mc -c 764c12b6 /tmp/IndexController.java -d /tmp
输出结果

5.redefine热更新代码
/tmp/com/kuaiban/app/controller/IndexController.class 是 上一步 mc 输出的结果

6.验证结果:
