We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
增强类后, 不改变重写的方法的参数名
增强类后, 重写的方法的参数名会变成arg0, arg1 .... , 由于业务程序需要反射获取参数名, 更改参数名会造成业务程序的bug
java -jar arthas-boot.jar [INFO] JAVA_HOME: D:\Program Files\Java\jre1.8.0_202 [INFO] arthas-boot version: 3.7.2 [INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER. * [1]: 2996 com.qualsen.QAIotBizApplication [2]: 7956 [3]: 18552 org.jetbrains.jps.cmdline.Launcher [4]: 3020 org.jetbrains.idea.maven.server.RemoteMavenServer36 1 [INFO] arthas home: C:\Users\zhu\.arthas\lib\3.7.2\arthas [INFO] Try to attach process 2996 [INFO] Found java home from System Env JAVA_HOME: D:\Program Files\Java\jdk1.8.0_202 [INFO] Attach process 2996 success. [INFO] arthas-client connect 127.0.0.1 3658 ,---. ,------. ,--------.,--. ,--. ,---. ,---. / O \ | .--. ''--. .--'| '--' | / O \ ' .-' | .-. || '--'.' | | | .--. || .-. |`. `-. | | | || |\ \ | | | | | || | | |.-' | `--' `--'`--' '--' `--' `--' `--'`--' `--'`-----' wiki https://arthas.aliyun.com/doc tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html version 3.7.2 main_class pid 2996 time 2024-02-19 10:04:41 [arthas@2996]$ ognl -c 18b4aac2 '@com.qualsen.thingsmind.biz.report.service.QtmpBizReportService1@class.getMethods()[0].getParameters()' @Parameter[][ @Parameter[java.lang.Object obj], ] [arthas@2996]$ watch com.qualsen.thingsmind.biz.report.service.QtmpBizReportService1 * '{params,returnObj,throwExp}' -n 5 -x 3 Press Q or Ctrl+C to abort. Affect(class count: 1 , method count: 2) cost in 65 ms, listenerId: 1 [arthas@2996]$ ognl -c 18b4aac2 '@com.qualsen.thingsmind.biz.report.service.QtmpBizReportService1@class.getMethods()[0].getParameters()' @Parameter[][ @Parameter[java.lang.Object arg0], ] [arthas@2996]$ reset Affect(class count: 1 , method count: 0) cost in 10 ms, listenerId: 0 [arthas@2996]$ ognl -c 18b4aac2 '@com.qualsen.thingsmind.biz.report.service.QtmpBizReportService1@class.getMethods()[0].getParameters()' @Parameter[][ @Parameter[java.lang.Object arg0], ] [arthas@2996]$
The text was updated successfully, but these errors were encountered:
这个是 JDK 自身的bug,参考: https://bugs.openjdk.org/browse/JDK-8240908
测试 jdk 17 仍然有,jdk 21是可以正常运行的。上面的issue显示是 jdk 19才修复。
可以自己简单写一个代码来测试,只要触发 retransformClasses,函数参数名称信息就会丢失。
retransformClasses
Method method = MathGame.class.getMethod("primeFactors", int.class); Parameter[] parameters = method.getParameters(); System.err.println("parameters.length: " + parameters.length); for (Parameter parameter : parameters) { System.err.println("parameter: " + parameter.getName()); System.err.println("parameter: " + parameter); } Instrumentation inst = ByteBuddyAgent.install(); inst.retransformClasses(MathGame.class);
Sorry, something went wrong.
No branches or pull requests
环境信息
重现问题的步骤
期望的结果
增强类后, 不改变重写的方法的参数名
实际运行的结果
增强类后, 重写的方法的参数名会变成arg0, arg1 .... , 由于业务程序需要反射获取参数名, 更改参数名会造成业务程序的bug
The text was updated successfully, but these errors were encountered: