Search code examples
byte-buddyjavapoet

ByteBuddy - how to save the Java source code?


It seems quite common to save the .class file with ByteBuddy Display generated bytebuddy bytecode

Would it be possible to save the Java source code (.java file) as well in some way?

I found saveIn(File) (https://bytebuddy.net/#/tutorial) can only write the byte code (.class file).

Any help to get this answered much appreciated.


Solution

  • If you need source code, you'd ideally generate it and compile it. Decompiling class files (there's tools for that too) is normally not equally reliable.