[alibaba/arthas]jad 后未作任何改动却 mc 内存编译失败

2024-07-09 243 views
2
环境信息
  • arthas-boot.jar 或者 as.sh 的版本: 3.4.4
  • Arthas 版本: 3.4.4
  • 操作系统版本: CentOS 7
  • 目标进程的JVM版本: 1.8.0_202
  • 执行arthas-boot的版本: 1.8.0_202
重现问题的步骤
  1. jad --source-only 某个含有匿名内部类的class
  2. mc 内存编译第 1 步的结果
  3. 异常
期望的结果

在未人为改变jad生成的java文件的情况下,希望mc 成功

实际运行的结果

Memory compiler error, exception message: Compilation Error line: 969 , message: expected , , please check $HOME/logs/arthas/arthas.log for more details.

jad生成的java文件,969行代码如下:
PlatformResponse platformResponse = (PlatformResponse)new Gson().fromJson(platformDetailsCache, new /* Unavailable Anonymous Inner Class!! */.getType());

对应的原始代码如下:
PlatformResponse platformResponse = new Gson().fromJson(platformDetailsCache, new TypeToken<PlatformResponse>() {}.getType());

对应$HOME/logs/arthas/arthas.log日志如下:
2021-09-07 09:03:07 [arthas-command-execute] WARN  c.t.a.c.c.k.MemoryCompilerCommand -Memory compiler error
com.taobao.arthas.compiler.DynamicCompilerException: Compilation Error
line: 969 , message: <identifier> expected ,

        at com.taobao.arthas.compiler.DynamicCompiler.buildByteCodes(DynamicCompiler.java:132)
        at com.taobao.arthas.core.command.klass100.MemoryCompilerCommand.process(MemoryCompilerCommand.java:137)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
        at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:385)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

回答

0

参考 mc/jad wiki,这个不能保证一定能成功。

8

额想问下不能保证成功的原因是什么呢?匿名内部类的原因吗?

8

后续版本会考虑完善一下吗?

6

反编译的功能是有限的。特别是有范型时处理不了,因为编译结果里没有范型信息。