问题
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:
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.
来源:https://stackoverflow.com/questions/29454667/how-do-i-get-the-method-body-using-javassist