- 我已经在 issues 里搜索,没有重复的issue。
环境信息
arthas-boot.jar
或者as.sh
的版本:3.1.4
- Arthas 版本:
3.1.4
- 操作系统版本:
macOS 10.15
(并且在Linux上能重现) - 目标进程的JVM版本:
1.8.0_222
- 执行
arthas-boot
的版本:1.8.0_222
重现问题的步骤
- 用旧代码启动进程
旧代码
public class Main {
private static void test(long val) {
System.out.println(val);
}
public static void main(String[] args) throws InterruptedException {
while (true) {
Thread.sleep(1000);
test(1L);
}
}
}
- 编译新代码,得到Main.class
新代码
public class Main {
private static void test(Long val) {
System.out.println(val);
}
public static void main(String[] args) throws InterruptedException {
while (true) {
Thread.sleep(1000);
test(1L);
}
}
}
- 启动arthas,执行命令
redefine /path/to/Main.class
期望的结果
redefine error! java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method
- 这也是java11下的表现*
实际运行的结果
- java8下*
redefine success, size: 1
说明重定义成功,但是主进程报错:
Exception in thread "main" java.lang.NoSuchMethodError: Main.test(J)V
at Main.main(Main.java:9)
5条答案
按热度按时间6jygbczu1#
将参数从int换成long,也会触发同样的错误
qv7cva1a2#
The redefinition must not add, remove or rename fields or methods, change the
signatures of methods, or change inheritance.
rmbxnbpk3#
That means redefining should failed, not redefining successfully, and the program cannot running.
It looks like a JDK's bug.
qqrboqgw4#
redefine 过程中无法检测语法
kqqjbcuj5#
"Exception in thread "main" java.lang.NoSuchMethodError" 异常应该跟jvm在解释执行选取方法过程有关。