[jboss-dev-forums] [Javassist development Forum] - Replacing the static method

azeem_is do-not-reply at jboss.com
Mon Jun 11 11:30:01 EDT 2007


I am new to javassist API. I need to do some task using byte code replacement. I have 3 classes something like given below


  | public class A {
  | 	public void method()
  | 	{
  | 		System.out.println("Method in A");
  | 	}
  | }
  | 
  | public class B{
  | 	public static void method()
  | 	{
  | 		System.out.println("Method in B");
  | 	}
  | }
  | 
  | public class C extends A{
  | 	public static void call()
  | 	{
  | 		method();
  | 	}
  | }
  | 
  | 

C.call() will print "Method in A". Now i need to replace A's method() with B's method() i.e C.call() should print "Method in B".

Please give some code snippet to do this task.

Thanks in advance

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4053158#4053158

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4053158



More information about the jboss-dev-forums mailing list