Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the method body using Javassist?

Tags:

javassist

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.

like image 531
addy Avatar asked Apr 05 '15 06:04

addy


1 Answers

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.

like image 84
Rafael Winterhalter Avatar answered Oct 10 '22 23:10

Rafael Winterhalter