you can do it at compile time by adding lines to the source file before compiling.I know the process of doing this. so I have no doubts in this.
you can do it statically, post-compilation by adding new byte code to the .class file.How to do this. what is the process. any api for this?
lastly, you can do it on-the-fly at runtime in a custom ClassLoader by reading the original class file byte codes, adding any additional byte code, then passing it along to the part of the jvm where byte codes are turned into actual Classes.how to do this? what is the process? may be in simple steps.