Play with your byte-code using Javassist
I came to know about this nice tool named javassist which is a cool java byte code manipulation tool.It provides users with a very easy to use API to modify / create java classes in the Runtime. It provides some API to do that using a Java like syntax so that we can easily hack the byte code without knowing any thing in-depth about the byte code structure. In this blog post I'll explain you a simple example on how to use this tool.This will show how we can use javassist to change the byte code of a compiled class to change a method implementation in Runtime. Step 1 Download javassist library from http://sourceforge.net/projects/jboss/files/Javassist/3.14.0.GA/ Step 2 Create a new directory and copy javassist.jar to that directory. Step 3 Create Two java source file named HelloWorld.java and ByteCodeInjector.java in that directry HelloWorld.java public class HelloWorld { public static void main(String[] args) { new HelloWorld().sayHello(); } public void sayHello(){ ...