Depending on what you really want to do, I do not recommend decompiling / modifying / recompiling the code (whether legal, official, understandable, reasonable).
Using bytecode may not be the best solution, but if you want to follow this path, look at the ASM project , this is a widespread bytecode manipulation scheme used by many well-known projects.
If I were you, I would first try aspects ( AspectJ .) The strength of the aspects is that you do not touch the existing code, but tell the virtual machine what to do when / before / after / instead of calling a specific method. This allows you to specify the exact context and change, improve the behavior of the code by writing your own code separately.
Hope this helps.
source share