How do I get the method body using Javassist?

前端 未结 1 666
予麋鹿
予麋鹿 2021-01-12 13:07

It is possible to set the method body using CtMethod.setBody(\"..\"), but I do not find any API to get the method body in string format.

相关标签:
1条回答
  • 2021-01-12 13:54

    This is not possible.

    Javassist is not a decompiler. A method in a class file is represented in Java byte code. Javassist knows how to translate Java source code to byte code but not the other way round. Also, Java byte code might not even be expressable as Java source code, for example when written in a non-Java JVM language.

    0 讨论(0)
提交回复
热议问题